Doctype

0 comments

Html 5 doctype

What is doctype:Doctype is Document type.This means what type of document it is.is it a word document or a image document or a html document?.

In previous html specifiacation is not strikely followed by the browser.As Html grow older it comes with specific rules and browser start to follow this rules.But web developer have to tell the browser which type of html(standard or old )they are using.This declaration is on the very top of html document.


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

This is html 4.01 doctype declaration.By this code of line browser realise how to handle the rest of the document.In short,Browser understand that this is html 4.01 document.But this long line of code is hard to remember to web developer.Thats why html 5 make it shorter and cleaner.

<!DOCTYPE html>

Now just write above one instead of two long line.If browser found this short and smart doctype,it assume this is a html document and its version is 5.Simple enough to remember and use.

Html 5 Charset Declaration:


Charset encoding tells the browser how to translate and render character to the front end for user.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

This is html 4.01 charset declaration.But too long and boring.So html make life more comfortable and simple.

<meta charset="utf-8">

Thats the html 5 charset declaration.we just need charset property and tell the brower what type of encoding we need.

HTML 4.01 VS HTML 5 Basic Structure


HTML 4.01 Structure


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>html 4.01  Document</title>
</head>

<body>
</body>
</html>


HTML 5 Structure

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>HTML 5 Document</title>
</head>

<body>
</body>
</html>



 

Copyright 2010 All Rights Reserved E-tech institute of IT.