HTML and CSS Reference
In-Depth Information
:lang() (Language Pseudo-class)
The language pseudo-class allows for selection based on the language of
the text.
article:lang(en) {} /* selects an article element in English */
article:lang(es) {} /* selects an article element in Spanish */
note This is different from selection based on lang or hreflang via the attri-
bute selector because the language pseudo-class may be inherited
from a parent element or defined as part of the document headers.
:root (Root Element Pseudo-class)
The root element pseudo-class is a shortcut to select the root node of the
document. For HTML documents, this is always the html element.
:nth-child() , :nth-last-child() (Nth Child
Pseudo-classes)
These pseudo-class selectors match elements that appear at a specific
position in a list of elements containing that list item and all its sibling
elements. The position is defined via the pattern a
b where a and b
n+
are integers.
The values odd and even are shortcuts to select every odd (or 2n+1 ) or
even ( 2n ) item.
“Zebra striping” a list of items or successive rows of a table ( Figure 3.1 on
the next page) can easily be accomplished via the nth-child pseudo-class
without the need for additional class names or other hooks in the docu-
ment markup.
tr { background-color: #FFF; color: #000; }
tr:nth-child(odd) { background-color: #AAA; }
 
 
 
 
Search WWH ::




Custom Search