Declare document language and viewport
#The document language helps assistive technology and language processing. A viewport declaration allows responsive CSS to work with the device viewport.
Fragment
Reference
Look up semantic HTML, forms, CSS layout, events, DOM operations and common browser APIs.
Modern browser platform examples, independent of a framework. HTML/CSS excerpts belong in the appropriate document/style context; DOM snippets assume a browser and named elements/data; TypeScript annotations clarify DOM types and need compilation or removal in plain JavaScript. Check target-browser support for newer features.
The document language helps assistive technology and language processing. A viewport declaration allows responsive CSS to work with the device viewport.
Fragment
Headings describe structure, landmarks identify regions, anchors navigate and buttons perform actions. A generic div does not acquire native keyboard behavior by looking like a button.
Fragment
alt supplies an image’s text alternative. An empty alt marks a decorative image; a missing alt and an intentionally empty alt have different meanings.
Fragment
Describe the image’s purpose in context, not merely its filename.
textContent creates text. innerHTML parses markup and can introduce injection when content is untrusted. HTML escaping, URL encoding and JavaScript string escaping are different operations.
Fragment
Deferred classic scripts and non-async module scripts run after parsing, in document order. Module scripts are deferred by default and resolve their import graph first. async scripts run as soon as they are ready, without ordering.
Fragment
Top-level await lets a module finish later than scripts that start after it: the order of starting is not the order of completion.