copenndthagen
copenndthagen

Reputation: 50722

Actual Use of Doctype

While I have gone through a lot of information on w3.org about Doctype and understand the different types of doctypes (Transitional, Strict, Frameset)

I am still not clear what is the actual use of using Doctype on pages?

I mean:

Please help me with the same. Thank you.

Upvotes: 5

Views: 396

Answers (4)

Sandip Gopani
Sandip Gopani

Reputation: 11

The doctype does impact the rendering, what tags are valid, which attributes they can have, and also how you can use them in client script. A transitional doctype is more forgiving than a strict, but the HTML version also affects what's valid.

The biggest difference is between having a doctype tag and not having one, especially in Internet Explorer. Without a doctype tag it will render the page in quirks mode, which among other things include use of the non-standard box model, which can mess up your layout completely.

You can visit http://www.teachw3.com/html_tutorial/html_home.php

Upvotes: 1

Rakshit Pai
Rakshit Pai

Reputation: 291

  1. Yes, if you use strict and then use deprecated tags, the page will not validate when you run it through the W3C validator

  2. Yes, it will impact rendering.

Without DocType, the browser will render you page using quirks mode, which is to say that certain tags will render differently on browsers. Some of these tags are now deprecated and some others have been standardized.

DocType (transitional & strict) are used to tell the browser that you are following the HTML standards and to render the markup as per the standard W3C spec.

Upvotes: 1

Guffa
Guffa

Reputation: 700152

It's to tell the browser how it should interpret the code in the page.

(If you use it as a tool to control developers, you have a management problem...)

The doctype does impact the rendering, what tags are valid, which attributes they can have, and also how you can use them in client script. A transitional doctype is more forgiving than a strict, but the HTML version also affects what's valid.

The biggest difference is between having a doctype tag and not having one, especially in Internet Explorer. Without a doctype tag it will render the page in quirks mode, which among other things include use of the non-standard box model, which can mess up your layout completely.

Upvotes: 6

Joachim Sauer
Joachim Sauer

Reputation: 308001

The Doctype will influence how a browser will parse your code. Since most browsers are pretty lenient when it comes to parsing HTML, the changes are not as massive as one might expect.

Note that HTML5 has a pretty well-defined parsing algorithm that even defines how ill-formed HTML is to be interpreted. On HTML5-enabled browsers this algorithm is used when the HTML5 doctype is present.

Upvotes: 1

Related Questions