Back to the index.
Selects an element that is the only child of its parent. Text nodes don't count; the parent element is allowed to have text node children.
Testsheet:
li:only-child {color: #CB000F;}
<ul>
has two child <li>
s.<ul>
has one child <li>
that should be red.What happens when we add an element to the last <ul>
? The red should be removed,
since the <li>
is not the only child of its parent any more.
Add an extra <li>
to the test UL.