HTML 5 Doctype and IE 6

杀马特。学长 韩版系。学妹 提交于 2019-12-03 18:40:36

问题


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:


Short answer: the HTML5 doctype works fine in IE6.

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




回答2:


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 to 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="dist/html5shiv.js"></script>
<![endif]-->


来源:https://stackoverflow.com/questions/3911235/html-5-doctype-and-ie-6

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!