Jump to content

The necessity of the doctype tag in HTML5 documents.


Scaramouche

Recommended Posts

Question. Why have the <!DOCTYPE html> at the top of an HTML document in HTML5? Before you give the standard answer ("So the document is interpreted as an HTML document."), think about it. All that is, is a line of plain text saying "HTML". The exact same thing happens when you have the <HTML> tag at the top of the html document. The same line of plain text is repeated. The same thing could be achieved by the interpreter reading that <html> tag. Unnecessary duplication should be avoided. Then there's the file extension as well, which once again serves the same purpose. Perhaps in earlier versions of HTML, it actually made a difference, when you had to specify which set of rules you were going by. However, if the move is toward only saying that it is HTML, then it becomes an unnecessary piece of duplication which should be removed entirely.

Link to comment
Share on other sites

HTML documents can have any extension. .php, .py, .jsp...The current need for <!DOCTYPE> in HTML 5 is so that browsers know the different between standards complient mode (has doctype) and quirks mode (has no doctype). If browsers suddenly start rendering documents that don't have a doctype in standards compliant mode then half of the internet would look wrong.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...