HTML and CSS Reference
In-Depth Information
Figure 3.1
Zebra striping, or
applying back-
ground colors to
alternating table
:first-child , :last-child (First and Last Child
The first-child and last-child pseudo-class selectors represent the first
and last children elements of some parent element. They are equivalent
to :nth-child(1) and :nth-last-child(1) , respectively.
These selectors can be extremely useful for the common design pattern
of using borders as a divider between a set of elements but not outside
them ( Figure 3.2 ).
li { border-top: 1px solid red; } /* place a border above all
li elements */
li:first-child { border-top: none; } /* remove the border
from the top of the first item */
Figure 3.2
Border on the
first-child list
item is removed.
Search WWH ::

Custom Search