Appendix B (^) ❘ 497
bapp02.indd 02/17/2015 Page 497
CHILD FILTERS
The following selectors make selections based on the position of children elements relative to
their siblings and their parents.
:nth-child(offset)
:nth-child(even)
:nth-child(odd)
:nth-child(equation)
Selects all elements where the element is a certain off-
set counting from zero, or elements that are in even or
odd positions (also determined by counting offset from
zero). You can also provide a mathematical expression
that will be evaluated to determine which elements are
matches.
:nth-last-child(offset)
:nth-last-child(even)
:nth-last-child(odd)
:nth-last-child(equation)
Similar to nth-child, but elements are selected based
on their offset position counting backward from the last
child of the parent.
:first-child Selects all elements where the element is the fi rst child
of its parent.
:last-child Selects all elements where the element is a last child of
its parent.
:only-child Selects all elements where the element is the only child
of its parent.
:first-of-type Matches the fi rst element of the specifi ed type, wher-
ever it may occur within the context of the selection. If
the selection is within the context of the entire docu-
ment and the selection div:first-of-type is used,
the fi rst occurrence of
element, wherever it may be, is matched.
:last-of-type Matches the last element of the specifi ed type within
the context of that element’s parent and siblings.
:nth-of-type(offset)
:nth-of-type(even)
:nth-of-type(odd)
:nth-of-type(equation)
Selects elements in relation to their parent and siblings
counting offset from zero, the fi rst element of the same
type.
:nth-last-of-type(offset)
:nth-last-of-type(even)
:nth-last-of-type(odd)
:nth-last-of-
type(equation)
Selects elements in relation to their parent and siblings
of the same type, counting from the last element of that
type.
continues
http://www.it-ebooks.info