Wednesday 16 January 2013

HTML Declaration



HTML5 uses a new form of document declaration in order to specify the language and HTML version the document uses.  

The format is much simpler than the previous dreadful HTML document type declarations (DTDs) - which I could never remember and always cut & pasted the correct one into new documents.

The new format is instantly recognizable due to its brevity and announces that the following document is HTML5.  For this reason the declaration should go at the head of each HTML5 document.

Here's how it looks:
<!DOCTYPE html>
Combining the declaration with the HTML tag (as above) is an acceptable practice, though on it's own the <!doctype> declaration is not an HTML tag.

The declaration is case-insensitive.  Uppercase, lowercase or a combination is acceptable (I see mostly uppercase in the wild with lowercase 'html' - just as I've written above).

The declaration is  supported by all the major browsers.  Any browser not recognizing it (are there any?) will default into standards mode.  Standards mode means that the browser will parse the HTML in a compliant way and ignore any HTML5 tags that are not supported.

No comments:

Post a Comment