Using the CSS :modal pseudo-selector
Blog post from LogRocket
Pseudo-elements and pseudo-classes in CSS, often referred to as pseudo-selectors, allow developers to style HTML elements in ways that are not directly represented in the markup, such as styling the placeholder text of input fields or creating modals without additional classes. Pseudo-elements, denoted by a double colon (::), represent parts of the DOM like ::before or ::after, enabling content insertion purely through CSS. Pseudo-classes, marked with a single colon (:), such as :first-child or :hover, allow styling based on an element's state and user interactions, reducing the need for excess classes in the markup. The article specifically highlights the :modal pseudo-selector, which simplifies the styling of modal elements by detecting their state intrinsically, allowing them to be styled without extra CSS classes. Through examples, it demonstrates how pseudo-elements and pseudo-classes enhance code efficiency, maintainability, and user interaction styling, particularly in complex web applications.