By HTML5 standards, the <html> tag, the <body> tag, and the <head> tag can be omitted, to reduce the complexity of the HTML document. When the <head> tag is omitted, browsers will create a default <head> element before the <body> tag.The following code will validate as HTML5:
HTML file: | Displayed by browser: |
---|---|
<!DOCTYPE html>
<title>Page Title</title> <h1>This is a heading</h1> <p>This is a paragraph.</p> (end of document) |
This is a headingThis is a paragraph. |
Take note that the <html> element is the document root, and the recommended place for specifying the page language. Declaring a language is important for accessibility applications (screen readers) and search engines:
Omitting these tags is not recommended! Omitting them can crash badly-written DOM/XML software or produce errors in older browsers (IE9).