Slide 5.22: CSS pseudo-class (cont.)
Slide 5.24: CSS pseudo-element
Home

CSS Pseudo-Class (Cont.)


CSS—The :first-child Pseudo-Class (Cont.)
Match all <i> element in all first child <p> elements
In the following example, the selector matches all <i> elements in <p> elements that are the first child of another element:

     

CSS—The :lang Pseudo-Class
The :lang pseudo-class allows you to define special rules for different languages. In the example below, the :lang class defines the quotation marks for q elements with lang="no":

     


Pseudo-Classes
The “CSS” column indicates in which CSS version the property is defined (CSS1 or CSS2).

Pseudo-class Purpose CSS
:active Adds special style to an activated element 1
:focus Adds special style to an element while the element has focus 2
:hover Adds special style to an element when you mouse over  it 1
:link Adds special style to an unvisited link 1
:visited Adds special style to a visited link 1
:first-child Adds special style to an element that is the first child of some other element 2
:lang Allows the author to specify a language to use in a specified element 2


Demonstration
The following demonstration shows how the script of HTML and CSS is displayed on the Web: