HTML and CSS Reference
In-Depth Information
You may be thinking to yourself that there
are a few situations in which you would
like to select elements that are both first
and last child, like the links in this example.
You can do this by combining the two
pseudo-classes:
ul :first-child:last-child {
background-color: #000;
}
This rule selects elements that are both a
first and a last child and are descendants of
the <ul> element. It's a bit of a mouthful,
though, so fortunately there's an alternative
pseudo-class that has the same effect:
ul :only-child {
background-color: #000;
}
:first-
child
:last-
child
:nth/:nth-last
child/of type
1.0
1.0
1.0
1.0
1.0
3.5
7.0
9.0
9.0
7.0
9.5
10.10
1.0
1.0
3.0
 
Search WWH ::




Custom Search