问题描述
因此,例如,如果我的HTML文档没有声明HTML5文档类型,但我在HTML5规范中使用了某些东西,那还能用吗?这是否会导致某些浏览器出现问题?文档是否仍会验证?
So, for example, if my HTML document does not declare the HTML5 doctype, but I use something in the HTML5 spec, will that still work? Does that cause problems for some browsers? Will the document still validate?
推荐答案
这取决于目标浏览器。 Webkit浏览器,Firefox和Opera将正常处理HTML5元素,即使你的doctype不是HTML5。
It depends on the target browsers. Webkit-browsers, Firefox and Opera will handle HTML5 elements quite normally even if your doctype is not HTML5.
另一方面IE9(我打赌你看到了这一点),可能在另一种类型的doctype上表现完全不同。如果IE9不处于IE9标准模式(可能是怪癖,IE8兼容,无论如何),它将不支持它在IE9标准中的HTML5功能。
IE9 on the other hand (I bet you saw this coming), may behave entirely differently on another type of doctype. If IE9 is not in IE9 Standards mode (it could be in quirks, IE8 compat, whatever), it will not support the HTML5 features it does in IE9 standards.
所以基本上你主要担心的是你需要确保所有浏览器都进入严格的标准模式。实现这一目标的最简单方法是使用HTML5文档类型,因为它将在所有浏览器中触发标准模式 - 包括实际上不支持HTML5的旧浏览器。
So essentially your main concern is that you need to make sure all browsers go into strict standards mode. The easiest way to achieve this is to use the HTML5 doctype, since it will trigger standards mode in all browsers - including older browsers that don't actually support HTML5.
这篇关于您是否可以在不声明HTML5 DOCTYPE的情况下使用HTML5功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!