Required elements and optional tags in HTML
In HTML, some elements have optional tags. In fact, both the opening and closing tags of some elements may be completely removed from an HTML document, even though the elements themselves are required. Does that seem a bit confusing?
It can seem strange, especially considering that three required HTML elements whose start and end tags are optional are the html, head, and body elements. Yes, you can leave those out of your markup in HTML (but not in XHTML). The browser will still create the elements, and they will be available in the document tree.
Still confused? Read Gez Lemon’s detailed explanation in Required Elements, and Required Tags.
- Previous post: Safari matters - support it or lose credibility
- Next post: Internet Explorer for the Mac is no more






Comments
I’m not sure if the use of this minimised markup is still legal … Anne considered to patent it! :)
IMHO, this is not something we should be encouraging.
Scott: I agree, but it's important to know about this.
The only reason for omitting the html, head, and body tags I can see is if you really, really need to save every possible byte of bandwidth.
There are other required elements that aren't touched on in the article, the most signifigant being <tbody>. When traversing a DOM tree to work with a table, it's important to remember that it's inserted into the DOM, even if it's not in the markup.
Sorry, comments are closed for this post.