HTML and CSS Reference
In-Depth Information
Alternately, this can also be done via :last-child :
li { border-bottom: 1px solid red; } /* place a border above
all li elements */
li:last-child { border-bottom: none; } /* remove the border
from the bottom of the last item */
:nth-of-type() , :nth-last-of-type() (Nth of Type
While nth-child() matches any element type, nth-of-type() and nth-
last-of-type() select every a
b element where the set of elements
is based on a collection of sibling elements that are only of the same
element type.
One application of the nth-of-type selector is to set alternating styles on
successive images found in a parent element regardless of what type of
content is between them.
:first-of-type , :last-of-type (First and Last of Type
Similarly to first-child and last child, there are the shortcuts
:first-of-type and :last-of-type , which represent :nth-of-type(1)
and :nth-last-of-type(1) , respectively.
:only-child (Only Child Pseudo-class)
This pseudo-class selects elements that are the only child of their parent
element. Any element selected by :only-child matches both the
:first-child and :last-child selectors.
Search WWH ::

Custom Search