tags:

views:

52

answers:

2

I often see this doctype declaration on some pages that I am viewing

<!DOCTYPE html>

I made some soft research and this is HTML 5 doctype declaration. Modern browsers can interpret this and would force to operate on Standards Mode.

My question is, some of my target users are still using IE6. How will IE6 responds when I declare such doctype declaration.?

Will I gain any benefit or loss in that case?

Thanks.

+1  A: 

There are no downsides to using the HTML5 doctype in IE6. The benefit is a shorter doctype that is easier to remember.

However, IE has an odd bug where if you use HTML5 tags that it doesn't already recognize, they can't be styled with CSS. The browser will act like the tag isn't there. The contents will still render fine though.

To work around this bug, if you call createElement with the name of the HTML5 tag you want to use in your page, the browser will then allow you to style them with CSS. So if you do this:

document.createElement('video');

Before any <video /> tags on your page, it will allow you to apply proper styling to the tag. Keep in mind the browser still won't actually do anything with the tag. You'll just be able to apply CSS it it.

In order to make this process easier, it is common practice to use this HTML5 shim library on your page. Just include this in your document before any CSS or HTML5 elements.

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"&gt;&lt;/script&gt;
<![endif]-->
Dan Herbert
+2  A: 

Short answer: the HTML5 doctype works fine in IE6.

Longer answer: see Henri Sivonen's comprehensive research of the affects of different doctypes on different browsers.

Brian Campbell
@Brian Excellent Blog you got there. Thanks!
Mark Estrada