Which mode is IE6 if doctype is html as HTML5?

前端 未结 1 1898
眼角桃花
眼角桃花 2021-01-31 20:13

If web page has doctype as HTML5.


Which render mode is it for IE6?

The document.compatMode tell

相关标签:
1条回答
  • 2021-01-31 20:27

    The HTML5 doctype was specifically chosen because it was the shortest doctype string possible that triggered standards mode in all browsers (starting with IE6). This was a deliberate decision based on what what would work in browsers that were already in use.

    In other words, if you specify <!doctype html>, IE6 should go into standards mode, not quirks mode.

    The reason it works is because IE6 (and others) are actually quite lenient on the doctype; they're making the assumption that if there's a doctype there, the developer probably intended to be in standards mode. If they don't recognise it, they're assuming that either the developer made a typo or there's been a new doctype invented that wasn't around when the browser was released; either way, the browser attempts to make the best of it and work in standards mode. The HTML5 team discovered that html was the shortest doctype string possible which triggered this behaviour, hence its use as the HTML5 doctype.

    What the HTML5 doctype doesn't do of course is trigger old browsers like IE6 to actually support any of the new HTML5 features. This is obvious really. Products like Modernizr and HTML5Shiv can help with that, but only up to a point.

    0 讨论(0)
提交回复
热议问题