FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

125 snippets foundClear filters
CSSResponsive design

Stack columns on small screens

Change a two-column CSS grid to one column at a viewport breakpoint.

CSS✓ Tested
CSSFlexbox alignment

Stack flex items vertically

CSS: Flex-direction column makes the main axis vertical.

CSS✓ Tested
CSSInteraction selectors

Style a card based on a selected descendant

CSS: Has matches the parent when its relative selector finds a checked control inside it.

CSS✓ Tested
CSSInteraction selectors

Style a control that fails native validation

CSS: Invalid reflects the input’s current constraint-validation result.

CSS✓ Tested
CSSInteraction selectors

Style content associated with a checked option

CSS: The adjacent-sibling selector connects a checked control with its following label text.

CSS✓ Tested
CSSTypography

Style list markers

Set marker color separately from list text using CSS ::marker.

CSS✓ Tested
CSSInteraction selectors

Style placeholder text independently of entered text

CSS: The placeholder pseudo-element affects the hint, while the input rule styles the actual value.

CSS✓ Tested
CSSType & reading flow

Style supporting text in italics

CSS: Font-style changes presentation without adding semantic emphasis by itself.

CSS✓ Tested
CSSGetting Started

Target a unique element by ID

CSS: Learn how to target a unique element by ID in a complete browser example.

CSS✓ Tested
CSSGetting Started

Target an element by class

CSS: Learn how to target an element by class in a complete browser example.

CSS✓ Tested
CSSTypography

Truncate a single line

Combine CSS overflow and ellipsis for a constrained single line.

CSS✓ Tested
CSSGetting Started

Underline meaningful text

CSS: Learn how to underline meaningful text in a complete browser example.

CSS✓ Tested