SGML

HTML5.2 DTD Reference

W3C HTML5(http://sgmljs.net/schemas/sgml-cms/w3c/html5.dtd)
DTD for W3C HTML 5 (deprecated); while the DTD itself is deprecated, the text describes the construction of the HTML 5 DTD in detail; see later versions for important revisions
W3C HTML5.1(http://sgmljs.net/schemas/sgml-cms/w3c/html51.dtd) (http://sgmljs.net/schemas/sgml-cms/w3c/html51mini.dtd)
Full DTD and Minimal DTD for W3C HTML 5.1 (superseded by HTML 5.2)
W3C HTML5.2 (http://sgmljs.net/schemas/sgml-cms/w3c/html52.dtd) (http://sgmljs.net/schemas/sgml-cms/w3c/html52mini.dtd)
Full DTD and Minimal DTD for W3C HTML 5.2 (superseded by HTML RD 200129)
HTML Review Draft 200129 (http://sgmljs.net/schemas/sgml-cms/w3c/html200129.dtd) (http://sgmljs.net/schemas/sgml-cms/w3c/html200129mini.dtd)
Full DTD and Minimal DTD for HTML Review Draft 200129; note the Minimal DTD is the declaration set resolved via the 'about:legacy-compat' system identifier in sgmljs.net SGML
HTML Review Draft 230116 (http://sgmljs.net/schemas/sgml-cms/w3c/html230116.dtd) (http://sgmljs.net/schemas/sgml-cms/w3c/html230116mini.dtd)
Full DTD and Minimal DTD for HTML Review Draft 230116 (experimental)
Note: the W3C HTML 5 series DTDs are deprecated and superseded by the HTML Review Draft (200129 and newer) DTDs. The current HTML RD 200129 Minimal DTD assumes SGML IMPLYDEF ELEMENT ANYOTHER behaviour with respect to undeclared elements as defined in ISO/IEC 8879:1986/Cor.2:1999(E) in support of SVG and MathML foreign vocabularies and custom elements. While IMPLYDEF ELEMENT ANYOTHER is supported by sgmljs.net SGML, it might not be by other SGML software such as OpenSP. If a minimal DTD for use with OpenSP is desired, use the legacy Minimal HTML 5.1 DTD. Note this only affects the minimal but not full DTD variants.

Overview

The Full HTML5.2 DTD, like former versions, is a transcription of WHATWG's HTML specification prose into an SGML DTD. If follows WHATWG snapshots as published by W3C (WHATWG itself doesn't publish stable snapshots of its specifications). The Full DTD covers all elements of HTML, SVG, MathML, and the ARIA attributes, and its construction is described in the reference for the W3C HTML 5 DTD, with only modifications for version 5.2 described in this document.

The Minimal HTML5.2 DTD, also like former versions, is a compact DTD containing only essential parsing rules for HTML. As only HTML's special rules for HTML void elements and enumerated attributes are included (others being admitted freely), the Minimal HTML5.2's DTD usefulness for validation purposes is limited. Instead, the purpose of the Minimal HTML5.2 DTD is to provide a minimal bundled declaration set for content parsing and production tasks for modern and idiomatic HTML in sgmljs.net and other SGML software with support for resolving declaration sets via catalog resolution (in sgmljs.net, the Minimal HTML5.2 DTD is resolved and accessed by the about:legacy-compat system identifier).

Update for W3C HTML5.2

Alignment with WHATWG HTML

According to the W3C HTML 5.2 recommendation text

At time of publication of this document, patches from the WHATWG HTML specification have been merged until January 12, 2016

Moreover,

The W3C HTML editors have also added patches that resulted from discussions and decisions made by the W3C Web Platform WG as well a bug fixes from bugs not shared by the WHATWG.

(for example, the revised content models for dt, allowing div as child element introduced into WHATWG with https://github.com/w3c/html/commit/ec2e514d525e7a7191d0287bf5b48a02f4d28312).

The W3C HTML5.2 recommendation documents their changes versus prior versions in Changes. The following subsections describe particular changes.

Additional declarations

This W3C HTML 5.2 DTD reflects changes made to W3C's latest HTML recommendation. For the Minimal DTD variant, element declarations for all elements that can be nested are added to block IMPLYDEF ELEMENT ANYOTHER inferring an end-element if a nested element occurs.

Updated SVG declarations

This W3C HTML incorporates an SVG DTD derived from the official SVG 1.1 2nd edition DTD, updated with support for the vector-effect attribute with its only permitted value non-scaling-stroke from SVG 1.2 using the SVG 1.1 2nd editions extensive customization features. This is in line with the W3C HTML 5.2 HTML specification text stating that

[...] 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. [...]

The Minimal DTD for HTML 5.2 now also contains declaration for SVG elements (but not attributes) to block SGML's interpretation of undeclared elements under IMPLYDEf ELEMENT ANYOTHER semantics (which would make SGML auto-close undeclared element such as SVG's g element when encountering a nested g element).

Additional changes

Removed keygen element

The keygen element has been removed from the HTML 5.2 version. Note that, unlike other removed elements, the keygen element is an SGML element with declared content EMPTY (a HTML void element), hence shouldn't be used with an end-element tag. The presence of elements with special parsing rules, however, requires a declaration for thse, hence the keygen element is not removed from the Minimal HTML 5.2 DTD.

Removed menu and menuitem elements

The menu and menuitem elements are removed, and this is reflected in updated content models and element-category parameter entities throughout.

The 'menuitem, like thekeygenelement, has been incorporated as a legacy element with declared contentEMPTY` into the Minimal DTD.

New dialog element

The dialog element has been added.

Global attributes

As reflected by changed DTD code text

  • the contextmenu global attribute and the oncontextmenu event handler attribute have been removed

  • the dropzone global element has been removed

  • the oncopy and oncut event handler attributes have been removed

  • the onauxclick and onloadend event handler attributes have been added.

Global attributes are declared via a parameter entity reference now that the specification text no longer specifies these individually on every element.

Body/window event handler attributes

The window or body event handler attributes, used to be specified separately in previous specifications, are now specified along with the body element. The following window event handler attributes are added:

  • onlagnguagechange

  • `onrejectedhandled'
  • ununhandledrejection

Relaxed dl content model

The updated grammar rules admit div elements as child content of dl elements (and seems to allow "inheriting" dd and dt content tokens into child div elements, similar to "transparent content"), when in older HTML grammar rules the content model of dl could be seen to infer/force dt elements. But actually, both dt and dd require start-element tags in both W3C HTML 5.1 and 5.2, so no inference opportunity is lost.

The schema change has a related change to the div element which is now required to have dt, dd pairs when the div element itself appears as direct child content of a dl element. This is, however, not completely reflected in the updated HTML 5.2 DTD; the 'divelement instead admitsdtanddl` elements anywhere in addition to flow elements (via a content model inclusion).

Content model for the legend element

The legend element now admits h1, ..., h6 elements as child element.

Tag omission on the colgroup element

The colgroup element admits start- and end-tag omission under specific conditions; this is reflected in the HTML 5.2 DTD's tag omission indicator for the colgroup eleement.

referrerpolicy attribute

The referrerpolicy attribute has been added to the a, img, iframe, area, and link elements.

longdesc attribute

The longdesc attribute has been added to the img element.

allowpaymentrequest attribute

The allowpaymentrequest attribute has been added to the iframe element.

Attributes for the source element

The srcset, sizes, and media attributes have been added to the source element.

dialog value for the method attribute of the form element

The new value dialog has been added to the method attribute of the form element.

autocomplete attribute of the select element

The autocomplete attribute has been added to the select element.

inputmode attribute of the textarea element

The inputmode attribute has been added to the textarea element.

Errata

The declaration of header and footer elements as given in previous DTD transcriptions for W3C HTML 5 and 5.1 didn't admit nested header or footer elements, respectively, when those are allowed by the specification text, eg.

... with no [...] header, footer elements that are not descendants of sectioning content wich is a descendant of the header [or footer, resp.]

is saying that child header or footer elements are only allowed within the child content of header or footer relements, resp., when these are in turn part of a child sectioning root (ie. not directly as child).

This can't be represented by exclusion exceptions, but must be declared by stating all directly admittted child elements (flow elements without header and footer elements) directly in a content model.

Update 03/2023

The following additional change was applied in March, 2023 (see also notes for HTML Review Draft 200129):

In previous DTDs, the ARIA role attribute wasn't actually declared (only attributes for ARIA states and properties were). This has been fixed. Note unlike role, the tabindex attribute is, and has always been, declared as part of HTML.

In previous versions, exclusion exceptions for the main element had been placed on div and legend elements when they should only apply to sectioning elements with explicit exclusion of main such as article, nav, and aside. Note main itself doesn't exclude main descendants in its content model.