DEV Community

Jens Oliver Meiert
Jens Oliver Meiert

Posted on • Originally published at meiert.com

4 1

On the Difficulty of Counting the Number of HTML Elements

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 actually 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 all difficulty and inaccuracy.

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (1)

Collapse
 
perpetual_education profile image
perpetual . education

This is great. We've gone through this through process a few times. Most people are looking for elements they need today.

Next post idea: "On figuring out which HTML elements are which display types" ?

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay