HTML 5 Doctype and IE 6

后端 未结 2 420
误落风尘
误落风尘 2020-12-24 14:52

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


I made some soft research and this is HTML 5 doc

相关标签:
2条回答
  • 2020-12-24 15:16

    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.

    0 讨论(0)
  • 2020-12-24 15:34

    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]-->
    
    0 讨论(0)
提交回复
热议问题