Which DOM elements cannot accept an id?

dom, html

Solution

In HTML5, the `id` attribute is a global attribute and can be specified on any element.

If you look through the Document Type Declaration for HTML4, you can find the elements which do not have `%attrs;` defined in their attribute list to indicate they do not support the `id` attribute. Those included are near the bottom in the "Document Head" section: `HEAD`, `TITLE`, `BASE`, `META`, `STYLE`, `SCRIPT`, and `HTML`.

Note that although the `PARAM` element does not include the `%attrs;` declaration in its attribute list, it does explicitly allow the `id` attribute itself in that list.

<!ATTLIST PARAM
  id          ID             #IMPLIED  -- document-wide unique id --
  name        CDATA          #REQUIRED -- property name --
  value       CDATA          #IMPLIED  -- property value --
  valuetype   (DATA|REF|OBJECT) DATA   -- How to interpret value --
  type        %ContentType;  #IMPLIED  -- content type for value
                                      when valuetype=ref --
  >

Problem

I'm reading this basic tutorial on `canvas` elements. The `(almost)` in the following sentence caught my eye: The id attribute isn't specific to the element but is one of the default HTML attributes which can be applied to (almost) every HTML element Which html elements cannot accept an id?

Original source