After all of the learning to set up a basic html5 page, we suddenly are now going to tell the browser that we are using html5 by using the "doctype element". The doctype* as the name suggest specifies the document type. Being an everyday evolving language, html has several versions and associated technologies and every individual has open options to use any of them according to their preference. The doctype defines information like which version of the html is used to write the document etc.
But as of this course of time html5 is the new common among developers and it greatly simplifies the doctype of the html document and shrinks it down to just a simple statement against the old long and terrifying DTD and Xhtml declarations (if you don't know what they are, don't worry; you don't need to).
The doctype is defined at the very beginning of the document even before the html element in the webpage. Now since, the doctype is a special element which is just for the purpose of defining the type of the html document, it has a sightly different syntax than other elements.
The doctype tag is surrounded by angle brackets as usual but starts with an exclamation mark '!' followed by the doctype declaration as "html". That's it.
<!DOCTYPE html>
(the doctype can also be written in smallcaps, it won't make a difference)
Test Code : ( The html5 page is ready to go )
<!doctype html>
<html>
<head>
<meta charset = "UTF-8">
<title>
My page still has a title within head tag
</title>
</head>
<body>
I can see my text appearing in the main content area.
All the content in the webpage is mentioned in this tag
</body>
<html>
Note: Similar to meta tag there will not be any difference in appearance of the page in the browser but now you specified the use of html5 and the new html5 elements can be used explicitly.
But as of this course of time html5 is the new common among developers and it greatly simplifies the doctype of the html document and shrinks it down to just a simple statement against the old long and terrifying DTD and Xhtml declarations (if you don't know what they are, don't worry; you don't need to).
The doctype is defined at the very beginning of the document even before the html element in the webpage. Now since, the doctype is a special element which is just for the purpose of defining the type of the html document, it has a sightly different syntax than other elements.
The doctype tag is surrounded by angle brackets as usual but starts with an exclamation mark '!' followed by the doctype declaration as "html". That's it.
<!DOCTYPE html>
(the doctype can also be written in smallcaps, it won't make a difference)
Test Code : ( The html5 page is ready to go )
<!doctype html>
<html>
<head>
<meta charset = "UTF-8">
<title>
My page still has a title within head tag
</title>
</head>
<body>
I can see my text appearing in the main content area.
All the content in the webpage is mentioned in this tag
</body>
<html>
Note: Similar to meta tag there will not be any difference in appearance of the page in the browser but now you specified the use of html5 and the new html5 elements can be used explicitly.
Comments
Post a Comment