CSS pseudo-classes are used to add some special effects to selectors.
Syntax of pseudo-class:
In browsers that support CSS, different states of links can be displayed in different ways
Note: In the CSS definition, a: active must be placed after a: hover to be valid.
Note: The names of the pseudo-classes are not case sensitive.
Pseudo-classes and CSS classes
Pseudo-classes can be used with CSS classes:
Hover on <div>
An case of utilizing the
:hover pseudo-class on a <div> element:
CSS: first-child pseudo-class
You can use the: first-child pseudo-class to select the first child element of the parent element.note：Must be declared before IE8<!DOCTYPE> ，Then: first-child takes effect.
Match the first element <p>In the following example, the selector matches the <p> element that is the first child of any element:
Match the first <i> celement of all <p>elementsIn the following example, the first <i> element of all matching <p> elements is selected:
Match all <i> elements in all <p> elements that are the first child elementIn the following example, the selector matches all <i> elements in all <p> elements that are the first child of the element:
CSS - The :lang Pseudo-class
: lang pseudo-classes give you the ability to define special rules for different languages
In the following example, the: lang class defines the type of quotes for q elements with an attribute value of no: