O'Reilly logo

HTML5: Your visual blueprint™ for designing rich web pages and applications by Adam McDaniel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required