There are many different versions of HTML over internet. Use of other web programming languages like JavaScript, JQuery, CSS and XML is very common on a lot of websites. Therefore to tell web browsers which version of HTML we have used in current document we use HTML Document type declaration or HTML version type declaration.
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
The very first line of example above displays a demonstration of how HTML DOCTYPE Declarations are used. We will explain it to you in detail now. The DOCTYPE declaration helps browsers understand which type of HTML that specific webpage is based upon. There are many documents available online over internet. A browser can only render a webpage correctly only if knows which type of HTML that webpage is using.
Below are some examples of DOCTYPE Declaration tags (What are HTML Tags?) According to HTML versions.
HTML 5
<!DOCTYPE html>
HTML 4.01
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
XHTML 1.0
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Note :
The DOCTYPE tag must be placed at very beginning on the webpage. Before <html> tag. This DOCTYPE declaration tag has no ending tag. It is an instruction to the browser about the HTML version type we are using in our webpage.
Difference between HTML 4.01 and HTML 5 DOCTYPE declarations:
In HTML 4.01 there are three methods to define a DOCTYPE tag. But HTML 5 has only one method to define DOCTYPE tag in a webpage. It is one of the many great improvements The HTML has made. Now the web developers and code writers have only one method to remember and use every time they develop Webpages
. That particular method is given below again for your knowledge.
The HTML Document Type Declaration |
<!DOCTYPE html>
This single line of code is enough to tell all browsers in world to consider that the webpage they are rendering is developed in HTML 5.
Useful Tips : _
- Always include complete DOCTYPE tag in all your web pages of website.
- You should note that DOCTYPE declaration tag has no ending tag. See our paper on (introduction of HTML Tag).
- There are many free HTML type validators online which will check that you have used correct type of HTML declaration. Just search them on Google and use it to check your document type.
No comments:
Post a Comment
All comments are subjected to moderation therefore they may take some time to appear. Thanks for your patience.