Show Sidebar

Declaring a document as HTML 5 with <!DOCTYPE html>

The very first thing that goes inside a HTML document is the “<!DOCTYPE html>” as seen in this example.

Purpose of DOCTYPE html

This statement is very important as it tells the browser that the document is an HTML 5 document and it must be parsed as HTML 5. As HTML versions have been evolving with time, each version includes new features and remove the features that are obsolete. There needs to be a way to identify one version from another. If you avoid this declaration it is up to the browser to guess which version you are using.

In the previous version’s declaration looks like this (4.01 transitional )

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “”>

The new declaration is shorter and can be easily remembered as compared to the ones in the version 4.01

Doctype html is case insensitive

As the rest of HTML document , this too is case insensitive. Which means you can write it all in upper case , or everything is lowercase.

So these ones are valid but not recommended to use.

<!doctype HTM>



©2019 Clean Tutorials