With the :first-child
pseudo-class,
you can select a particular type of
element if its the first
child of its parent. For example,
span:first-child
selects a span
element, only if its the first
child of its parent. So, in the
following example, nothing is selected:
But if you want to select the
first span
element within its
parent, whether or not it is the
first child, you can use span:first-of-type
instead:
:last-child
and :last-of-type
work in
the same manner.
Try using these two pseudo-classes
in place of :first-of-type
to
understand how they work.