HTML and CSS Reference
In-Depth Information
The :last-child pseudo-class represents the last child of the selected element.
p:last-child {} /* last paragraph child */
This rule targets the last child of the following paragraph element.
<em>Last child</em>
The :only-child pseudo-class matches elements that do not have any siblings.
p:only-child {} /* children without siblings */
This rule is applied to the following first <strong> element because it is the only
child of the paragraph. The second paragraph element has two children, so none of them
is targeted by this rule.
<strong>Only child</strong>
As its name implies, the :only-of-type selector matches the selected element only if it
does not have any siblings of the same type.
p:only-of-type {} /* only <p> element */
The following paragraph is targeted by this rule because it is the only paragraph
element of its parent.
<p>Only of type</p>
Search WWH ::

Custom Search