span:nth-child(2n+1)
, WITHOUT an
<em>
among the child elements.
Children 1, 3, 5, and 7 are selected.
Span 1!
Span 2
Span 3!
Span 4
Span 5!
Span 6
Span 7!
span:nth-child(2n+1)
, WITH an
<em>
among the child elements.
Children 1, 5, and 7 are selected.
3 is used in the counting because it is a child, but it isn't
selected because it isn't a <span>
.
Span!
Span
This is an `em`.
Span
Span!
Span
Span!
Span
span:nth-of-type(2n+1)
, WITH an
<em>
among the child elements.
Children 1, 4, 6, and 8 are selected.
3 isn't used in the counting or selected because it is an <em>
,
not a <span>
, and nth-of-type
only selects
children of that type. The <em>
is completely skipped
over and ignored.
Span!
Span
This is an `em`.
Span!
Span
Span!
Span
Span!