About this specification

This specification is like no other — it has been processed with you, the humble web developer, in mind.

The focus of this specification is readability and ease of access. Unlike the full HTML Standard, this "developer's edition" removes information that only browser vendors need know. It is automatically produced from the full specification by our build tooling, and thus always in sync with the latest developments in HTML.

To read about its conception, construction, and future, read the original press release, and the blog post about its relaunch.

Finally, feel free to contribute on GitHub to make this edition better for everyone!

  1. 2 Common infrastructure
    1. 2.1 Terminology
      1. 2.1.1 Resources
      2. 2.1.2 XML compatibility
      3. 2.1.3 DOM trees
      4. 2.1.4 Scripting
      5. 2.1.5 Plugins
      6. 2.1.6 Character encodings
      7. 2.1.7 Dependencies
      8. 2.1.8 Extensibility
    2. 2.2 Case-sensitivity and string comparison

2 Common infrastructure

This specification depends on the WHATWG Infra standard. [INFRA]

2.1 Terminology

This specification refers to both HTML and XML attributes and IDL attributes, often in the same context. When it is not clear which is being referred to, they are referred to as content attributes for HTML and XML attributes, and IDL attributes for those defined on IDL interfaces. Similarly, the term "properties" is used for both JavaScript object properties and CSS properties. When these are ambiguous they are qualified as object properties and CSS properties respectively.

Generally, when the specification states that a feature applies to the HTML syntax or the XML syntax, it also includes the other. When a feature specifically only applies to one of the two languages, it is called out by explicitly stating that it does not apply to the other format, as in "for HTML, ... (this does not apply to XML)".

This specification uses the term document to refer to any use of HTML, ranging from short static documents to long essays or reports with rich multimedia, as well as to fully-fledged interactive applications. The term is used to refer both to Document objects and their descendant DOM trees, and to serialized byte streams using the HTML syntax or the XML syntax, depending on context.

In the context of the DOM structures, the terms HTML document and XML document are used as defined in the DOM specification, and refer specifically to two different modes that Document objects can find themselves in. [DOM] (Such uses are always hyperlinked to their definition.)

In the context of byte streams, the term HTML document refers to resources labeled as text/html, and the term XML document refers to resources labeled with an XML MIME type.


For simplicity, terms such as shown, displayed, and visible might sometimes be used when referring to the way a document is rendered to the user. These terms are not meant to imply a visual medium; they must be considered to apply to other media in equivalent ways.

The term "transparent black" refers to the color with red, green, blue, and alpha channels all set to zero.

2.1.1 Resources

The specification uses the term supported when referring to whether a user agent has an implementation capable of decoding the semantics of an external resource. A format or type is said to be supported if the implementation can process an external resource of that format or type without critical aspects of the resource being ignored. Whether a specific resource is supported can depend on what features of the resource's format are in use.

For example, a PNG image would be considered to be in a supported format if its pixel data could be decoded and rendered, even if, unbeknownst to the implementation, the image also contained animation data.

An MPEG-4 video file would not be considered to be in a supported format if the compression format used was not supported, even if the implementation could determine the dimensions of the movie from the file's metadata.

What some specifications, in particular the HTTP specification, refer to as a representation is referred to in this specification as a resource. [HTTP]

A resource's critical subresources are those that the resource needs to have available to be correctly processed. Which resources are considered critical or not is defined by the specification that defines the resource's format.

2.1.2 XML compatibility

To ease migration from HTML to XML, UAs conforming to this specification will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS. The term "HTML elements" refers to any element in that namespace, even in XML documents.

Except where otherwise stated, all elements defined or mentioned in this specification are in the HTML namespace ("http://www.w3.org/1999/xhtml"), and all attributes defined or mentioned in this specification have no namespace.

The term element type is used to refer to the set of elements that have a given local name and namespace. For example, button elements are elements with the element type button, meaning they have the local name "button" and (implicitly as defined above) the HTML namespace.

Attribute names are said to be XML-compatible if they match the Name production defined in XML and they contain no U+003A COLON characters (:). [XML]

2.1.3 DOM trees

When it is stated that some element or attribute is ignored, or treated as some other value, or handled as if it was something else, this refers only to the processing of the node after it is in the DOM.

A content attribute is said to change value only if its new value is different than its previous value; setting an attribute to a value it already has does not change it.

The term empty, when used for an attribute value, Text node, or string, means that the length of the text is zero (i.e., not even containing controls or U+0020 SPACE).

A node A is inserted into a node B when the insertion steps are invoked with A as the argument and A's new parent is B. Similarly, a node A is removed from a node B when the removing steps are invoked with A as the removedNode argument and B as the oldParent argument.

A node is inserted into a document when the insertion steps are invoked with it as the argument and it is now in a document tree. Analogously, a node is removed from a document when the removing steps are invoked with it as the argument and it is now no longer in a document tree.

A node becomes connected when the insertion steps are invoked with it as the argument and it is now connected. Analogously, a node becomes disconnected when the removing steps are invoked with it as the argument and it is now no longer connected.

A node is browsing-context connected when it is connected and its shadow-including root has a browsing context. A node becomes browsing-context connected when the insertion steps are invoked with it as the argument and it is now browsing-context connected. A node becomes browsing-context disconnected either when the removing steps are invoked with it as the argument and it is now no longer browsing-context connected, or when its shadow-including root no longer has a browsing context.

2.1.4 Scripting

The construction "a Foo object", where Foo is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface Foo".

An IDL attribute is said to be getting when its value is being retrieved (e.g. by author script), and is said to be setting when a new value is assigned to it.

If a DOM object is said to be live, then the attributes and methods on that object operate on the actual underlying data, not a snapshot of the data.

2.1.5 Plugins

The term plugin refers to a user-agent defined set of content handlers used by the user agent that can take part in the user agent's rendering of a Document object, but that neither act as child browsing contexts of the Document nor introduce any Node objects to the Document's DOM.

Typically such content handlers are provided by third parties, though a user agent can also designate built-in content handlers as plugins.

One example of a plugin would be a PDF viewer that is instantiated in a browsing context when the user navigates to a PDF file. This would count as a plugin regardless of whether the party that implemented the PDF viewer component was the same as that which implemented the user agent itself. However, a PDF viewer application that launches separate from the user agent (as opposed to using the same interface) is not a plugin by this definition.

This specification does not define a mechanism for interacting with plugins, as it is expected to be user-agent- and platform-specific. Some UAs might opt to support a plugin mechanism such as the Netscape Plugin API; others might use remote content converters or have built-in support for certain types. Indeed, this specification doesn't require user agents to support plugins at all. [NPAPI]

A plugin can be secured if it honors the semantics of the sandbox attribute.

For example, a secured plugin would prevent its contents from creating pop-up windows when the plugin is instantiated inside a sandboxed iframe.

2.1.6 Character encodings

A character encoding, or just encoding where that is not ambiguous, is a defined way to convert between byte streams and Unicode strings, as defined in the WHATWG Encoding standard. An encoding has an encoding name and one or more encoding labels, referred to as the encoding's name and labels in the Encoding standard. [ENCODING]

A UTF-16 encoding is UTF-16BE or UTF-16LE. [ENCODING]

An ASCII-compatible encoding is any encoding that is not a UTF-16 encoding. [ENCODING]

Since support for encodings that are not defined in the WHATWG Encoding standard is prohibited, UTF-16 encodings are the only encodings that this specification needs to treat as not being ASCII-compatible encodings.

2.1.7 Dependencies

This specification relies on several other underlying specifications.

Infra

The following terms are defined in the WHATWG Infra standard: [INFRA]

Unicode and Encoding

The Unicode character set is used to represent textual data, and the WHATWG Encoding standard defines requirements around character encodings. [UNICODE]

This specification introduces terminology based on the terms defined in those specifications, as described earlier.

The following terms are used as defined in the WHATWG Encoding standard: [ENCODING]

XML and related specifications

Implementations that support the XML syntax for HTML must support some version of XML, as well as its corresponding namespaces specification, because that syntax uses an XML serialization with namespaces. [XML] [XMLNS]

Data mining tools and other user agents that perform operations on content without running scripts, evaluating CSS or XPath expressions, or otherwise exposing the resulting DOM to arbitrary content, may "support namespaces" by just asserting that their DOM node analogues are in certain namespaces, without actually exposing the namespace strings.

In the HTML syntax, namespace prefixes and namespace declarations do not have the same effect as in XML. For instance, the colon has no special meaning in HTML element names.


The attribute with the tag name xml:space in the XML namespace is defined by the XML specification. [XML]

The Name production is defined in the XML specification. [XML]

This specification also references the <?xml-stylesheet?> processing instruction, defined in the Associating Style Sheets with XML documents specification. [XMLSSPI]

This specification also non-normatively mentions the XSLTProcessor interface and its transformToFragment() and transformToDocument() methods. [XSLTP]

URLs

The following terms are defined in the WHATWG URL standard: [URL]

A number of schemes and protocols are referenced by this specification also:

Media fragment syntax is defined in the Media Fragments URI specification. [MEDIAFRAG]

HTTP and related specifications

The following terms are defined in the HTTP specifications: [HTTP]

The following terms are defined in the Cookie specification: [COOKIES]

  • cookie-string
  • receives a set-cookie-string
  • `Cookie` header

The following term is defined in the Web Linking specification: [WEBLINK]

The following terms are defined in the WHATWG MIME Sniffing standard: [MIMESNIFF]

Fetch

The following terms are defined in the WHATWG Fetch standard: [FETCH]

The following terms are defined in Referrer Policy: [REFERRERPOLICY]

The following terms are defined in Mixed Content: [MIX]

Web IDL

The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [WEBIDL]

The following terms are defined in the Web IDL specification:

The Web IDL specification also defines the following types that are used in Web IDL fragments in this specification:

The term throw in this specification is used as defined in the Web IDL specification. The DOMException type and the following exception names are defined by Web IDL and used by this specification:

When this specification requires a user agent to create a Date object representing a particular time (which could be the special value Not-a-Number), the milliseconds component of that time, if any, must be truncated to an integer, and the time value of the newly created Date object must represent the resulting truncated time.

For instance, given the time 23045 millionths of a second after 01:00 UTC on January 1st 2000, i.e. the time 2000-01-01T00:00:00.023045Z, then the Date object created representing that time would represent the same time as that created representing the time 2000-01-01T00:00:00.023Z, 45 millionths earlier. If the given time is NaN, then the result is a Date object that represents a time value NaN (indicating that the object does not represent a specific instant of time).

JavaScript

Some parts of the language described by this specification only support JavaScript as the underlying scripting language. [JAVASCRIPT]

Users agents that support JavaScript must also implement the ECMAScript Internationalization API Specification. [JSINTL]

The term "JavaScript" is used to refer to ECMA-262, rather than the official term ECMAScript, since the term JavaScript is more widely known. Similarly, the MIME type used to refer to JavaScript in this specification is text/javascript, since that is the most commonly used type, despite it being an officially obsoleted type according to RFC 4329. [RFC4329]

The following terms are defined in the JavaScript specification and used in this specification:

DOM

The Document Object Model (DOM) is a representation — a model — of a document and its content. The DOM is not just an API; the conformance criteria of HTML implementations are defined, in this specification, in terms of operations on the DOM. [DOM]

Implementations must support DOM and the events defined in UI Events, because this specification is defined in terms of the DOM, and some of the features are defined as extensions to the DOM interfaces. [DOM] [UIEVENTS]

In particular, the following features are defined in the WHATWG DOM standard: [DOM]

The following features are defined in the UI Events specification: [UIEVENTS]

The following features are defined in the Touch Events specification: [TOUCH]

The following features are defined in the Pointer Events specification: [POINTEREVENTS]

This specification sometimes uses the term name to refer to the event's type; as in, "an event named click" or "if the event name is keypress". The terms "name" and "type" for events are synonymous.

The following features are defined in the DOM Parsing and Serialization specification: [DOMPARSING]

The Selection interface is defined in the Selection API specification. [SELECTION]

User agents are encouraged to implement the features described in the execCommand specification. [EXECCOMMAND]

The following parts of the WHATWG Fullscreen API standard are referenced from this specification, in part to define the rendering of dialog elements, and also to define how the Fullscreen API interacts with HTML: [FULLSCREEN]

The High Resolution Time specification provides the DOMHighResTimeStamp typedef and the Performance interface's now() method. [HRT]

File API

This specification uses the following features defined in the File API specification: [FILEAPI]

Indexed Database API

This specification uses cleanup Indexed Database transactions defined by the Indexed Database API specification. [INDEXEDDB]

Media Source Extensions

The following terms are defined in the Media Source Extensions specification: [MEDIASOURCE]

Media Capture and Streams

The following terms are defined in the Media Capture and Streams specification: [MEDIASTREAM]

XMLHttpRequest

This specification references the XMLHttpRequest specification to describe how the two specifications interact and to use its ProgressEvent features. The following features and terms are defined in the XMLHttpRequest specification: [XHR]

Battery Status

The following features are defined in the Battery Status API specification: [BATTERY]

Media Queries

Implementations must support Media Queries. The <media-condition> feature is defined therein. [MQ]

CSS modules

While support for CSS as a whole is not required of implementations of this specification (though it is encouraged, at least for Web browsers), some features are defined in terms of specific CSS requirements.

When this specification requires that something be parsed according to a particular CSS grammar, the relevant algorithm in the CSS Syntax specification must be followed. [CSSSYNTAX]

In particular, some features require that a string be parsed as a CSS <color> value. When parsing a CSS value, user agents are required by the CSS specifications to apply some error handling rules. These apply to this specification also. [CSSCOLOR] [CSS]

For example, user agents are required to close all open constructs upon finding the end of a style sheet unexpectedly. Thus, when parsing the string "rgb(0,0,0" (with a missing close-parenthesis) for a color value, the close parenthesis is implied by this error handling rule, and a value is obtained (the color 'black'). However, the similar construct "rgb(0,0," (with both a missing parenthesis and a missing "blue" value) cannot be parsed, as closing the open construct does not result in a viable value.

The following terms and features are defined in the CSS specification: [CSS]

The CSS specification also defines the following border properties: [CSS]

Border properties
Top Bottom Left Right
Width 'border-top-width' 'border-bottom-width' 'border-left-width' 'border-right-width'
Style 'border-top-style' 'border-bottom-style' 'border-left-style' 'border-right-style'
Color 'border-top-color' 'border-bottom-color' 'border-left-color' 'border-right-color'

The terms intrinsic width and intrinsic height refer to the width dimension and the height dimension, respectively, of intrinsic dimensions.

The basic version of the 'display' property is defined in the CSS specification, and the property is extended by other CSS modules. [CSS] [CSSRUBY] [CSSTABLE]

The following terms and features are defined in the CSS Logical Properties specification: [CSSLOGICAL]

The following terms and features are defined in the CSS Color specification: [CSSCOLOR]

The term paint source is used as defined in the CSS Image Values and Replaced Content specification to define the interaction of certain HTML elements with the CSS 'element()' function. [CSSIMAGES]

The term default object size and the 'object-fit' property are also defined in the CSS Image Values and Replaced Content specification. [CSSIMAGES]

The following features are defined in the CSS Backgrounds and Borders specification: [CSSBG]

The term block-level is defined in the CSS Display specification. [CSSDISPLAY]

The following features are defined in the CSS Fonts specification: [CSSFONTS]

The 'list-style-type' property is defined in the CSS Lists and Counters specification. [CSSLISTS]

The 'overflow' property and its 'hidden' value are defined in the CSS Overflow specification. [CSSOVERFLOW]

The following features are defined in the CSS Positioned Layout specification: [CSSPOSITION]

The 'ruby-base' value of the 'display' property is defined in the CSS Ruby Layout specification. [CSSRUBY]

The following features are defined in the CSS Table specification: [CSSTABLE]

The following features are defined in the CSS Text specification: [CSSTEXT]

The following features are defined in the CSS Writing Modes specification: [CSSWM]

The following features are defined in the CSS Basic User Interface specification: [CSSUI]

Implementations that support scripting must support the CSS Object Model. The following features and terms are defined in the CSSOM specifications: [CSSOM] [CSSOMVIEW]

The following features and terms are defined in the CSS Syntax specifications: [CSSSYNTAX]

The following terms are defined in the Selectors specification: [SELECTORS]

The following features are defined in the CSS Values and Units specification: [CSSVALUES]

The term style attribute is defined in the CSS Style Attributes specification. [CSSATTR]

The following terms are defined in the CSS Cascading and Inheritance specification: [CSSCASCADE]

The CanvasRenderingContext2D object's use of fonts depends on the features described in the CSS Fonts and Font Loading specifications, including in particular FontFace objects and the font source concept. [CSSFONTS] [CSSFONTLOAD]

The following interfaces and terms are defined in the Geometry Interfaces Module specification: [GEOMETRY]

Intersection Observer

The following term is defined in the Intersection Observer specification: [INTERSECTIONOBSERVER]

WebGL

The following interface is defined in the WebGL specification: [WEBGL]

WebVTT

Implementations may support WebVTT as a text track format for subtitles, captions, chapter titles, metadata, etc, for media resources. [WEBVTT]

The following terms, used in this specification, are defined in the WebVTT specification:

The WebSocket protocol

The following terms are defined in the WHATWG Fetch standard: [FETCH]

The following terms are defined in the WebSocket protocol specification: [WSP]

  • the WebSocket connection is established
  • extensions in use
  • subprotocol in use
  • a WebSocket message has been received
  • send a WebSocket Message
  • fail the WebSocket connection
  • close the WebSocket connection
  • start the WebSocket closing handshake
  • the WebSocket closing handshake is started
  • the WebSocket connection is closed (possibly cleanly)
  • the WebSocket connection close code
  • the WebSocket connection close reason
  • Sec-WebSocket-Protocol field
ARIA

The role attribute is defined in the ARIA specification, as are the following roles: [ARIA]

In addition, the following aria-* content attributes are defined in the ARIA specification: [ARIA]

Finally, the following terms are defined in the ARIA specification: [ARIA]

Content Security Policy

The following terms are defined in Content Security Policy: [CSP]

Service Workers

The following terms are defined in Service Workers: [SW]

Secure Contexts

The following terms are defined in Secure Contexts: [SECURE-CONTEXTS]

Payment Request API

The following feature is defined in the Payment Request API specification: [PAYMENTREQUEST]

MathML

While support for MathML as a whole is not required by this specification (though it is encouraged, at least for Web browsers), certain features depend upon small parts of MathML being implemented. [MATHML]

The following features are defined in the MathML specification:

SVG

While support for SVG as a whole is not required by this specification (though it is encouraged, at least for Web browsers), certain features depend upon parts of SVG being implemented.

Also, the SVG specifications do not reflect implementation reality. Implementations implement subsets of SVG 1.1 and SVG Tiny 1.2. Although it is hoped that the in-progress SVG 2 specification is a more realistic target for implementations, until that specification is ready, user agents that implement SVG must do so with the following willful violations and additions. [SVG] [SVGTINY12] [SVG2]

User agents that implement SVG must not implement the following features from SVG 1.1:

  • The tref element
  • The cursor element (use CSS's cursor property instead)
  • The font-defining SVG elements: font, glyph, missing-glyph, hkern, vkern, font-face, font-face-src, font-face-uri, font-face-format, and font-face-name (use CSS's @font-face instead)
  • The externalResourcesRequired attribute
  • The enable-background property
  • The contentScriptType and contentStyleType attributes (use the type attribute on the SVG script and style elements instead)

User agents that implement SVG must implement the following features from SVG Tiny 1.2:

  • The non-scaling-stroke value for the vector-effect property
  • The class attribute is allowed on all SVG elements
  • The tabindex attribute is allowed on visible SVG elements
  • The ARIA accessibility attributes are allowed on all SVG elements

The following features are defined in the SVG specifications:

Filter Effects

The following feature is defined in the Filter Effects specification: [FILTERS]

Worklets

The following feature is defined in the Worklets specification: [WORKLETS]


This specification does not require support of any particular network protocol, style sheet language, scripting language, or any of the DOM specifications beyond those required in the list above. However, the language described by this specification is biased towards CSS as the styling language, JavaScript as the scripting language, and HTTP as the network protocol, and several features assume that those languages and protocols are in use.

A user agent that implements the HTTP protocol must implement HTTP State Management Mechanism (Cookies) as well. [HTTP] [COOKIES]

This specification might have certain additional requirements on character encodings, image formats, audio formats, and video formats in the respective sections.

2.1.8 Extensibility

Vendor-specific proprietary user agent extensions to this specification are strongly discouraged. Documents must not use such extensions, as doing so reduces interoperability and fragments the user base, allowing only users of specific user agents to access the content in question.


When vendor-neutral extensions to this specification are needed, either this specification can be updated accordingly, or an extension specification can be written that overrides the requirements in this specification. When someone applying this specification to their activities decides that they will recognize the requirements of such an extension specification, it becomes an applicable specification for the purposes of conformance requirements in this specification.

Someone could write a specification that defines any arbitrary byte stream as conforming, and then claim that their random junk is conforming. However, that does not mean that their random junk actually is conforming for everyone's purposes: if someone else decides that that specification does not apply to their work, then they can quite legitimately say that the aforementioned random junk is just that, junk, and not conforming at all. As far as conformance goes, what matters in a particular community is what that community agrees is applicable.

2.2 Case-sensitivity and string comparison

Comparing two strings in a case-sensitive manner means comparing them exactly, code point for code point.

Except where otherwise stated, string comparisons must be performed in a case-sensitive manner.

A string pattern is a prefix match for a string s when pattern is not longer than s and truncating s to pattern's length leaves the two strings as matches of each other.