Gosub selectors & pseudo-elements test

Structural pseudo-classes, combinators, attribute selectors, generated content, interactive states, and typographic pseudo-elements.

Structural: :first/last-child, :nth-child

:nth-child(odd) tints alternate rows; :nth-child(3n) recolors every third.

:not()

Combinators

Direct child (>) — tinted
Descendant (italic)

Element A

Adjacent sibling of A (+) — red

General sibling of A (~) — green

Another general sibling — green

Attribute selectors + generated content

Secure link — gets a lock via [href^="https"]

Report — gets a (pdf) tag via [href$=".pdf"]

Opens in new tab — dotted underline

Active / Off — styled by data-state

::before / ::after

Featured product

Generated quotation marks wrap this text.

Items in cart

Interactive states (hover / focus / active / checked)

Hover this link

::first-line / ::first-letter

The first line of this paragraph is bold and blue, and the very first letter is enlarged as a floated drop-cap. Resize the window to confirm that ::first-line tracks the actual rendered first line rather than the source markup. Lorem ipsum dolor sit amet, consectetur adipiscing elit sed do eiusmod.

::selection

Select this text with your cursor — the highlight should be purple-on-white via ::selection.