I often see this doctype declaration on some pages that I am viewing
我经常在我正在查看的某些页面上看到此doctype声明
<!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.
我做了一些软研究,这是HTML 5 doctype声明。现代浏览器可以解释这一点并强制在标准模式下运行。
My question is, some of my target users are still using IE6. How will IE6 responds when I declare such doctype declaration.?
我的问题是,我的一些目标用户仍在使用IE6。当我声明这样的doctype声明时,IE6将如何响应。
Will I gain any benefit or loss in that case?
在这种情况下,我会获得任何利益或损失吗?
Thanks.
谢谢。
2 个解决方案
#1
18
Short answer: the HTML5 doctype works fine in IE6.
简短回答:HTML5 doctype在IE6中运行良好。
Longer answer: see Henri Sivonen's comprehensive research of the effects of different doctypes on different browsers.
更长的答案:请参阅Henri Sivonen对不同文档类型对不同浏览器的影响的综合研究。
#2
10
There are no downsides to using the HTML5 doctype in IE6. The benefit is a shorter doctype that is easier to remember.
在IE6中使用HTML5 doctype没有任何缺点。好处是更短的文档类型,更容易记住。
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.
但是,IE有一个奇怪的错误,如果你使用它尚未识别的HTML5标签,它们就无法用CSS设置样式。浏览器的行为就像标签不存在一样。虽然内容仍然很好。
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:
要解决此错误,如果您使用要在页面中使用的HTML5标记的名称调用createElement,则浏览器将允许您使用CSS设置样式。所以,如果你这样做:
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.
在页面上的任何 标记之前,它允许您对标记应用适当的样式。请记住,浏览器仍然不会对标记执行任何操作。你只需要将CSS应用于它。
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.
为了简化此过程,通常的做法是在页面上使用此HTML5填充程序库。只需在任何CSS或HTML5元素之前将其包含在您的文档中。
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->
#1
18
Short answer: the HTML5 doctype works fine in IE6.
简短回答:HTML5 doctype在IE6中运行良好。
Longer answer: see Henri Sivonen's comprehensive research of the effects of different doctypes on different browsers.
更长的答案:请参阅Henri Sivonen对不同文档类型对不同浏览器的影响的综合研究。
#2
10
There are no downsides to using the HTML5 doctype in IE6. The benefit is a shorter doctype that is easier to remember.
在IE6中使用HTML5 doctype没有任何缺点。好处是更短的文档类型,更容易记住。
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.
但是,IE有一个奇怪的错误,如果你使用它尚未识别的HTML5标签,它们就无法用CSS设置样式。浏览器的行为就像标签不存在一样。虽然内容仍然很好。
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:
要解决此错误,如果您使用要在页面中使用的HTML5标记的名称调用createElement,则浏览器将允许您使用CSS设置样式。所以,如果你这样做:
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.
在页面上的任何 标记之前,它允许您对标记应用适当的样式。请记住,浏览器仍然不会对标记执行任何操作。你只需要将CSS应用于它。
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.
为了简化此过程,通常的做法是在页面上使用此HTML5填充程序库。只需在任何CSS或HTML5元素之前将其包含在您的文档中。
<!--[if lt IE 9]>
<script src="dist/html5shiv.js"></script>
<![endif]-->