HTML Concepts: The “Nothing” Content Model
Post from June 17, 2021 (↻ December 17, 2021), filed under Web Development.
In this little series that started with the meaning of “body-ok,” let’s move to a trivial but little-known concept: the “nothing” content model.
What is it? It literally means what it says:
When an element’s content model is nothing, the element must contain no
Textnodes (other than inter-element whitespace) and no element nodes.
If this reminds of “empty” or void elements, then because it made sense to make elements that have nothing as content, elements that require no end tag. Having a content model of “nothing” and being a void element are not identical, however, as the spec explains:
Most HTML elements whose content model is “nothing” are also, for convenience, void elements (elements that have no end tag in the HTML syntax). However, these are entirely separate concepts.
You notice “most”: Not all elements with the “nothing” content model are void elements. Best example? The
template element. This is because contents of
template are not children of the element itself.
Is this series interesting? Let me know in the comments (when still open) or as a response to my tweet for this post.
I’m Jens Oliver Meiert, and I’m an engineering manager and author. I’ve worked as a technical lead for Google, I’m close to the W3C and the WHATWG, and I write and review books for O’Reilly. Other than that, I love trying things, sometimes including philosophy, art, and adventure. Here on meiert.com I share some of my views and experiences.
If you have questions or suggestions about what I write, please leave a comment (if available) or a message.
Have a look at the most popular posts, possibly including:
Looking for a way to comment? Comments have been disabled, unfortunately.
Perhaps my most comprehensive book: The Web Development Glossary (2020). With explanations and definitions for literally thousands of terms from Web Development and related fields, building on Wikipedia as well as the MDN Web Docs. Available at Apple Books, Kobo, Google Play Books, and Leanpub.