Omitting the html
, and body
tags is certainly allowed by the HTML specs. The underlying reason is that browsers have always sought to be consistent with existing web pages, and the very early versions of HTML didn't define those elements. When HTML
first did, it was done in a way that the tags would be inferred when missing.
In the HTML5 standard, the <html> tag, the <body> tag, and the <head> tag can be omitted.
The following code will validate as HTML5:
<h1>This is a heading</h1>
This is a paragraph.
More details: Stackoverflow: Is it necessary to write HEAD, BODY and HTML tags?