Prev | Current Page 140 | Next

Tommy Olsson and Paul O'Brien

"The Ultimate CSS Reference"


The pseudo-class accepts an argument,
N, which can be a keyword, a number,
or a number expression of the form
an+b. For more information, see
Understanding :nth-child Pseudo-class
Expressions (p. 95).
Example
This example selector will match the last
row of any table:
tr:nth-last-child(1) {
?‹® declarations
}
If N is a number or a number expression, N matches elements that are followed by
N siblings in the document tree.
This example selector will match the last four list items in any list, be it ordered or
unordered:
li:nth-last-child(-n+4) {
?‹® declarations
}
This selector will match any paragraph that??™s the last child element of its parent
element:
p:nth-last-child(1) {
?‹® declarations
}
This is, of course, equivalent to the selector p:last-child (p. 98).
SPEC
CSS3
BROWSER SUPPORT
Op9.2 Saf3 FF2 IE7
NONE NONE NONE NONE
93 Selector Reference
Compatibility
Opera Safari Firefox Internet Explorer
9.2 3.0 2.0 1.3 2.0 1.5 1.0 7.0 6.0 5.5
None None None None None None None None None None
This pseudo-class is currently supported only by the Konqueror web browser.


Pages:
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152