Which mode is IE6 if doctype is html as HTML5?

大兔子大兔子 提交于 2019-12-02 18:41:22

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.

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