Pseudo-classes and pseudo-elements were added to CSS in version 2.1 and even more were added in CSS3. These style selectors are a way to give you more flexibility in what part of an element or class of element you want to style. For example, the most commonly used pseudo-classes are used on links to change how the link looks when it was visited (
:visisted pseudo-class) or when someone mouses over the link (
:hover pseudo-class). In fact, you may have used those pseudo-classes without even knowing they were pseudo-classes. Do you use pseudo-elements and/or pseudo-classes? Do you have any favorites? Share in the comments.
Some Pseudo-Elements and Pseudo-Classes You May Not Know
:lang--To style elements with different languages differently.
:not--To style every element except the one defined.
:nth-child--To style child elements that match a numerical pattern (the third child, all even children, etc.)
::selection--To style content on a page when a reader highlights or selects it.