HTML: The Markup Language

3. Documents # T

This section defines the term document, and provides additional details related to the definition of that term. It is divided into the following parts:

3.01. The HTML language and HTML and XML syntaxes # T

The term document is used in this specification to mean an instance of the HTML language.

The HTML language is the language described in this specification; it is an abstract language that applications can potentially represent in memory in any number of possible ways, and that can be transmitted using any number of possible concrete syntaxes.

This specification makes reference to two particular concrete syntaxes for the HTML language: One syntax which is referred to throughout this specification as the HTML syntax, and another syntax, which is referred to throughout this specification as the XML syntax. Web browsers typically implement two separate parsers for processing documents: an HTML parser which is invoked when processing documents in the HTML syntax, and an XML parser which is invoked when processing documents in the XML syntax.

The HTML syntax is the syntax described in the HTML syntax section of this specification.

The XML syntax is defined by rules in the XML specification [XML] and in the Namespaces in XML 1.0 specification [XMLNS]. Beyond the requirements defined in those specifications, this specification does not define any additional syntax-level requirements for documents in the XML syntax.

3.02. The HTML namespace and MIME types # T

The HTML namespace is defined as http://www.w3.org/1999/xhtml. The HTML namespace is the namespace both for documents in the HTML syntax and for documents in the XML syntax.

Documents that are served with the text/html MIME type must conform to the rules in this specification for documents in the HTML syntax.

Documents that have an HTML namespace declaration and that are served with an XML MIME type such as text/xml, application/xml, or application/xhtml+xml must conform to the rules in this specification for documents in the XML syntax.

3.03. Conformant documents # T

A conformant document in the HTML syntax must consist of the following parts, in the following order:

  1. Optionally, a single U+FEFF BYTE ORDER MARK (BOM) character.
  2. Any number of comments and space characters.
  3. A doctype.
  4. Any number of comments and space characters.
  5. An html element, with its attributes and contents.
  6. Any number of comments and space characters.

Documents in the HTML syntax must conform to the syntax described in the HTML syntax section of this specification.

A conformant document in the XML syntax must be a well-formed XML document, as defined in the XML specification [XML], and its root element, as defined in the XML specification [XML], must be an html element.

Documents in the XML syntax must conform to XML constraints as defined in the XML specification [XML] and in the Namespaces in XML 1.0 specification [XMLNS] — including XML well-formedness constraints — and must not make use of any features of the HTML syntax that do not follow XML well-formedness constraints (for example, documents in the XML syntax must not use unquoted attribute value syntax and must not omit tags).

3.04. Case insensitivity in tag names and attribute names # T

In documents in the HTML syntax:

In documents in the XML syntax: