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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.