FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
HTMLNative disclosure & dialogs

Show the current value of a range input

HTML: Mirror range input events into a labeled output for a native slider.

HTML✓ Tested
HTMLTables & list numbering

Span a group header across several rows

HTML: Rowspan can label a group of related rows without repeating the label.

HTML✓ Tested
HTMLTables & list numbering

Span one header across several columns

HTML: Colspan lets a heading cover a defined number of columns in the table grid.

HTML✓ Tested
HTMLNative disclosure & dialogs

Start a disclosure open while keeping it collapsible

HTML: The open attribute sets the initial details state without JavaScript.

HTML✓ Tested
HTMLDocument structure

Structure a document with headings

Use a single page heading and a second-level section heading in HTML.

HTML✓ Tested
HTMLForm behavior

Submit a readonly value while preventing edits

HTML: Readonly controls remain in form data, unlike disabled controls.

HTML✓ Tested
HTMLMetadata & document links

Suggest a browser interface color

HTML: Theme-color is a browser chrome hint and does not style the page itself.

HTML✓ Tested
HTMLMetadata & document links

Supply a title and URL for link previews

HTML: Open Graph metadata describes a shared page without changing its visible content.

HTML✓ Tested
HTMLNative disclosure & dialogs

Toggle a native popover from a button

HTML: The popovertarget relationship handles show and hide behavior without a click handler.

HTML✓ Tested
HTMLGetting Started

Use headings to show document structure

HTML: Learn how to use headings to show document structure in a complete browser example.

HTML✓ Tested
HTMLGetting Started

Use semantic page landmarks

HTML: Learn how to use semantic page landmarks in a complete browser example.

HTML✓ Tested
HTMLInput constraints

Validate a structured text identifier

HTML: The pattern attribute matches the entire nonempty input; required handles the empty case.

HTML✓ Tested