SELECT AN HTML ELEMENT USING THE STRUCTURAL CHILD PSEUDO-CLASS

As mentioned earlier, a pseudo-class is a list of predefined names that a web browser uses to match a specific structure of elements. In CSS2, the :first-child pseudo-class was introduced. In CSS3, the list was expanded to allow you to match new combinations and patterns of child elements.

The structural child pseudo-class matches the first-level descendents of a parent element:

element:first-child { ... }element:last-child { ... }element:only-child { ... }element:nth-child(counter) { ... }element:nth-last-child(counter) { ... }

element: first-child matches the first element, when the element specified is the first child found underneath its parent. If a different element is the ...

Get HTML5: Your visual blueprint™ for designing rich web pages and applications now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.