Want to know DOCTYPE TAG usage in html

Asked By 50 points N/A Posted on -
qa-featured

While using html the first tag we often use is <!DOCTYPE HTML> . I mistakenly removed this tag and starts with <html> tag. The web page still worked fine and there was no problem with it.Anyone can tell me what is the use of doctype tag when there is no problem in using it?

SHARE
Answered By 0 points N/A #187613

Want to know DOCTYPE TAG usage in html

qa-featured

Dear Randolph J Parks,

First of all clear one misconception"<!Doctype>" is not a HTML tag (although it is in angle brackets), It is an instruction to the web browser that to which version of HTML the page is written in.

There are many different types of Doctype. I am listing here only three (most popular) of them.

1. HTML 5:

<!doctype html>

2. HTML4.01 strict:

<!doctype html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

3. HTML 4.01 Transitional:

<!doctype HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

It interprets the browser how to deal with CSS and HTML. If you do not use the Doctype at the top of the page browser might misguess that you are using a different language version and hence rendered the page incorrectly. This can be more easily judge when you use "CSS"  height and width commands without declaring doctype,  they will disturb the page padding and border.

Related Questions