HTML Document DOC Type Tutorial

Below is a simple HTML document and each part is explained in detail.


<!DOCTYPE html>
<html>
<head>
<!--- JS/CSS file is to be added here -->

</head>
<body>

<h1>CodesBright demo heading</h1>

<p>Content goes here.</p>

</body>
</html>


The first line <!DOCTYPE html> is used to indicate (to the browser) what type the document is. This declaration is given based on which version of HTML to use. For example, the above document is an HTML5 document. Thus if it were version 1.0 of XHTML, the declaration would have been given like this


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


It is transitional, meaning you can write all HTML  in this document and use deprecated elements like the font. You cannot use a frameset.


However, replacing "xhtml1-transitional.dtd" with "xhtml1-strict.dtd" will prevent deprecated elements from being used.


** These are no longer commonly used now that HTML5 has arrived. Declaration of HTML 5 is given.


<!DOCTYPE html>


However, it is not very important. Copy and paste the HTML document at the beginning of writing. But you have to give it because if you don't provide it, some browsers don't output correctly, like Internet Explorer (IE).