--- name: html5-reference description: Use when authoring, reviewing, or validating HTML markup — choosing the right element, deciding what may nest inside what, writing forms/inputs, adding accessible semantics, or checking a document against the WHATWG living standard. Covers elements, content categories, global attributes, forms, and HTML-defined APIs. --- # HTML5 Reference (WHATWG Living Standard) ## Overview HTML5 is not "a set of tags you can put anywhere." The [WHATWG HTML Living Standard](https://html.spec.whatwg.org/multipage/) defines, for every element, **which content category it belongs to**, **where it is allowed to appear**, and **what it is allowed to contain**. Correct HTML is markup that satisfies these *content model* rules. **Core principle:** Pick the element whose semantics match the content's meaning, then verify the nesting is valid per the content model. Meaning first, appearance never (styling is CSS's job). This skill is the authoritative-but-condensed reference. It is version-current with the spec (living standard) — when in doubt, the linked multipage spec is the source of truth. ## When to Use - Deciding **which element** is correct (`
` vs `
` vs `
`; `` vs ``; `
` vs ``). - Checking whether a nesting is **valid** ("can a `
` go inside a `

`?" — no; "can an `` wrap block content?" — yes, it's transparent). - Building **forms**: choosing an `` type, wiring up labels, native constraint validation. - Adding **accessible semantics**: native element vs ARIA, landmarks, labeling. - Reviewing HTML for **conformance** / removing deprecated markup. **Not for:** CSS layout/styling, JS framework patterns, or build tooling. For this repo's web-dashboard conventions (Bootstrap/vanilla JS), that's a separate concern. ## The Content Model in One Picture Every element declares content **categories** (what it *is*) and a **content model** (what it may *contain*). An element may appear only where its categories are allowed. | Category | Meaning | Examples | |----------|---------|----------| | **Metadata** | Configures the document / links resources | `base` `link` `meta` `style` `title` `script` `noscript` | | **Flow** | Almost everything usable in `` | `p` `div` `section` `table` `img` `a` `span` `input` … | | **Sectioning** | Scopes headings/footers into a section | `article` `aside` `nav` `section` | | **Heading** | Section headings | `h1`–`h6` `hgroup` | | **Phrasing** | Text-level markup (roughly "inline") | `a` `em` `strong` `span` `code` `img` `input` `br` … | | **Embedded** | Imports external/other-namespace content | `img` `video` `audio` `canvas` `iframe` `svg` `object` | | **Interactive** | User-operable / focusable | `a`(href) `button` `input` `select` `textarea` `details` `label` | | **Palpable** | Non-empty, perceivable content | most flow/phrasing that isn't hidden/empty | | **Script-supporting** | Doesn't render; supports scripting | `script` `template` | **Golden nesting rules (memorize these):** - **Phrasing-only parents** (`

`, `

`–`
`, ``, `