Skip to content ↓

Proper HTML5 doctype

In HTML notation of HTML5, the DOCTYPE declaration is formally case-independent, so different variants of the doctype are in use, for example:

  • <!doctype html>

However HTML5 has an XML notation known as XHTML5. In XML, keywords (DOCTYPE in this case) must be in uppercase while element names are case-sensitive: for example, <p></p> and <P></P> are not the same thing. In XHTML, must be in lowercase. The html substring in DOCTYPE is the name of the document’s root element, so it must also be in lowercase:

<!DOCTYPE html>

Therefore this is the canonical form of doctype and is preferred regardess of particular HTML5 notation used.


The DOCTYPE declaration is located at the beginning of HTML-document code and is required to switch web browser to the standards-compliance mode. Only this mode can ensure that HTML page is rendered consistently across browsers. (Browser is a computer program for viewing websites.)

If a webpage does not have the DOCTYPE (or has a wrong DOCTYPE), then browsers display the page in mode compatible with old browsers — including even simulation of their bugs. Also, some modern features (e. g. support for the padding CSS-property for the IMG element) are available solely in the standards-compliance mode. HTML documents should always have the DOCTYPE declaration.