The snippet library.
Small, practical examples. Search by task or narrow things down below.
Create a complete HTML document
HTML: Learn how to create a complete HTML document in a complete browser example.
HTML✓ Tested
Create a native disclosure
Use details and summary to show optional HTML content without JavaScript.
HTML✓ Tested
Create a small table with headers
HTML: Learn how to create a small table with headers in a complete browser example.
HTML✓ Tested
Create an ordered list
Represent a sequence of steps using an HTML ordered list.
HTML✓ Tested
Declare a preferred canonical URL
HTML: A canonical link identifies the preferred public URL for duplicate representations of a document.
HTML✓ Tested
Declare an indexing preference for a draft page
HTML: A robots meta element can request noindex while allowing link following.
HTML✓ Tested
Declare document language and encoding
Set the HTML language, UTF-8 encoding and viewport for accessible responsive content.
HTML✓ Tested
Declare the document language and encoding
HTML: Learn how to declare the document language and encoding in a complete browser example.
HTML✓ Tested
Describe terms in a definition list
HTML: Learn how to describe terms in a definition list in a complete browser example.
HTML✓ Tested
Disable a related group of controls
HTML: A disabled fieldset prevents editing its descendant controls and omits them from form submission.
HTML✓ Tested
Dismiss a modal with the Escape key
HTML: Native modal dialogs provide keyboard dismissal and return focus to their invoker.
HTML✓ Tested
Display a calculated form result
HTML: An output element can name the input controls contributing to its value.
HTML✓ Tested