On the Peculiarities of Counting the Number of HTML Elements
Published on Jan 17, 2022 (updated Sep 26, 2023), filed under development, html (feed). (Share this on Mastodon or Bluesky?)
How many HTML elements are there?
What looks like a fairly simple question, isnât one:
- Are you looking for the number of HTML elements in the current and living specification?
- Are you looking for the number of HTML elements in a different HTML specification? (Which one?)
- Are you looking for the number of HTML elements from all HTML specifications?
- Are you looking for the number of HTML elements that were ever considered, i.e., that are also part of HTML drafts?
- Are you also looking for proprietary HTML elements?
- Are you looking for the number of HTML elements that are supported? (What does âsupportedâ mean?)
- Do you count container elements from other specifications, particularly
<svg>
and<math>
, as elements of HTML, or not? - (How) do you count custom elements? (The HTML specification indicates the entire class of elements as one element, and regularly, someone trips over this.)
- Do you make a distinction between HTML and XHTML?
The answers to these questions lead to different answers about the number of HTML elements.
Many people may want to know the number of HTML elements as per the current specification. That still leaves the question how they treat SVG and MathML as well as custom elements. Custom elements are not countable and should probably be ignored. If <svg>
and <math>
are considered elements of their respective specifications, as of today June 2, 2022, the answer is 111; if <svg>
and <math>
are considered HTML elements, 113.
If youâre looking for the number of HTML and XHTML elements formally specified, the answer is 131 or 133, that is, without or with <svg>
and <math>
. (I maintain an HTML elements index that makes this easy to tell.)
If youâre looking for all elements specified in HTMLÂ 1, itâs 22 elements; in HTMLÂ 2.0, 49 elements; in HTMLÂ 3.2, 70 elements; in HTMLÂ 4.01, 91 elements; in (unofficial) HTMLÂ 5.2, 111 elements. In XHTMLÂ 1.0, 91 elements; but in XHTMLÂ 1.1, a âstrictâ spec, 83 elements.
You notice that the answer to the number of HTML elements isnât difficult; it only needs qualification because there isnât one number of HTML elements. When you talk about the number of HTML elements, make clear what youâre including and excluding; and when youâre reading about it, check on what the author is including and excluding. This way, you avoid ambiguity and inaccuracy.
If youâre curious about all the HTML elements, check out aforementioned HTML elements index! Itâs up-to-dateâand when you find a mistake, Iâm happy to stand corrected and might pay or donate for the correction.
About Me
Iâm Jens (long: Jens Oliver Meiert), and Iâm a web developer, manager, and author. Iâve been working as a technical lead and engineering manager for companies youâve never heard of and companies you use every day, Iâm an occasional contributor to web standards (like HTML, CSS, WCAG), and I write and review books for OâReilly and Frontend Dogma.
I love trying things, not only in web development and engineering management, but also in other areas like philosophy. Here on meiert.com I share some of my experiences and views. (I value you being critical, interpreting charitably, and giving feedback.)