FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
HTMLMetadata & document links

Mark the language of a phrase inside a page

HTML: An element-level lang attribute identifies a language change within the document.

HTML✓ Tested
HTMLLinks & accessibility

Mark up a machine-readable date

Pair a readable date with an ISO datetime attribute in HTML.

HTML✓ Tested
HTMLAccessible structure

Move focus to a heading without adding a tab stop

HTML: A negative tabindex permits programmatic focus while keeping the heading out of ordinary sequential tab navigation.

HTML✓ Tested
HTMLImages & embedded documents

Name a meaningful image with alternative text

HTML: Alt supplies an accessible text alternative describing the image’s purpose.

HTML✓ Tested
HTMLImages & embedded documents

Name a self-contained embedded document

HTML: Give an iframe a descriptive title and provide its small document with srcdoc.

HTML✓ Tested
HTMLLinks & accessibility

Name an icon button

Give a button containing only a symbol an accessible name.

HTML✓ Tested
HTMLAccessible structure

Name complementary content

HTML: Aside identifies supporting content related to the main document.

HTML✓ Tested
HTMLMetadata & document links

Offer a downloadable text file

HTML: The download attribute supplies a filename for this same-document data URL.

HTML✓ Tested
HTMLForms

Offer a selection list

Provide a labeled HTML select with a default option.

HTML✓ Tested
HTMLText semantics

Offer an optional break inside a long label

HTML: Wbr supplies a potential line-break opportunity without inserting a visible hyphen.

HTML✓ Tested
HTMLLinks & accessibility

Open a link in a separate tab

Declare a separate browsing context with an explicit noopener relationship.

HTML✓ Tested
HTMLNative disclosure & dialogs

Open and close a modal dialog

HTML: showModal places a dialog in the top layer and makes the rest of the document inert.

HTML✓ Tested