views:

71

answers:

3

Do we use doctype only to render webpages in standard mode with IE6 ? or does doctype do something more than that?

+2  A: 

The doctype actually tells ALL browsers the type of content in the page. In many browsers, you'll notice very little difference, but in IE it has two different rendering modes, so you'll see a larger difference.

You should be using a doctype on all of your HTML documents. The idea is that it will be a much simpler doctype in the future - HTML 5 looks like this:

<!DOCTYPE html>

Whereas HTML 4 is like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;

And has Transitional or Strict options.

Sohnee
so if we do not use doctype then we won't get much differences in FF, opera , safari
metal-gear-solid
IE has four modes unfortunately (IE8 anyway). Here's a fun flowchart: http://hsivonen.iki.fi/doctype/ie8-mode.png
Steerpike
Other browsers also behave very differently depending on the doctype. See http://en.wikipedia.org/wiki/Quirks_mode
Joey
+1  A: 

It's not just IE6, it tells all browsers how to attempt to render the page.

Good information here and here.

Steerpike
A: 

Doctype could also used to check that your page respects the W3C standard.

Lastnico