简体   繁体   English

HTML5和Internet Explorer?

[英]HTML5 and Internet Explorer?

May be my question sounds stupid but I was wondering if it is possible to make Internet explorer (7 and 8) to recogonize HTML5 tags such as header, footer, section, aside etc, without using javascript ie. 可能是我的问题听起来很愚蠢,但我想知道是否有可能使Internet Explorer(7和8)无需使用javascript即重新设置HTML5标签(例如页眉,页脚,部分,旁边等)。 with css only? 仅使用CSS?

Thanks 谢谢

nope, it's not possible, you have to use JS 不,不可能,您必须使用JS

you could create elements.. eg 您可以创建元素..例如

document.createElement("header");  
document.createElement("footer"); 
document.createElement("section");
document.createElement("aside"); 

or 要么

this link may help How can I use HTML5 in all browsers including IE7,8? 该链接可能有帮助。 如何在包括IE7,8的所有浏览器中使用HTML5?

IE8 was released long before the HTML5 spec, so it's not surprising that neither IE7 nor IE8 support any of the HTML5 features. IE8早于HTML5规范发布,因此IE7和IE8都不支持任何HTML5功能也就不足为奇了。

The only way to make IE8 or earlier recognise and support elements which it doesn't know about is to use a Javascript hack. 使IE8或更早版本识别和支持未知的元素的唯一方法是使用Java hack。 This hack is available stand-alone in the form of HTML5Shiv , and is also built into the Modernizr feature detection library. 此hack可以HTML5Shiv的形式独立提供 ,也内置于Modernizr功能检测库中。

There is no other way to make IE work with HTML5. 没有其他方法可以使IE与HTML5一起使用。 So the basic answer to your question is "No". 因此,您的问题的基本答案是“否”。 Sorry. 抱歉。 There is no CSS-only solution. 没有纯CSS解决方案。 (in fact even the Javascript solution is a hack which exists more by luck than anything else; it certainly isn't something that MS intended to write into IE) (实际上,即使Javascript解决方案也是一种黑客,运气比其他任何事物都多;它当然不是MS打算写入IE的东西)

If you don't want to do the Javascript hack, then your best bet is simply not to use the HTML5 tags at all; 如果您不想进行Java hack,那么最好的选择就是根本不使用HTML5标签。 use <div> elements instead, with suitably semantic classnames. 请使用<div>元素,并使用适当的语义类名。

Of course, even with this hack, all you're doing is allowing IE to recognise that the new tags are valid HTML; 当然,即使有这种黑客攻击,您所做的就是允许IE识别新标记是有效的HTML;它只是使IE能够识别新标记而已。 you aren't actually adding any features to IE, so using any of the HTML5 stuff that provides new functionality (such as Canvas or the new input types) is still not going to work. 您实际上并未在IE中添加任何功能,因此使用提供新功能(例如Canvas或新的输入类型)的任何HTML5素材仍然无法正常工作。 There are separate Javascript tools for a number of these features, but beware of performance issues if you try to do to much (IE7/8 aren't exactly quick at the best of times). 对于其中的许多功能,有单独的Javascript工具,但是如果您尝试做很多事情,请提防性能问题(IE7 / 8在最佳情况下并不是很快)。

it's possible http://debeterevormgever.nl/en/articles/html5-elements-ie-without-javascript 有可能http://debeterevormgever.nl/zh-CN/articles/html5-elements-ie-without-javascript

but it will not validate 但不会验证

html HTML

<html xmlns="http://www.w3.org/1999/xhtml" xmlns:html5="http://www.w3.org/1999/xhtml">
    <body>
        <html5:section>...</html5:section>
    </body>
</html>

css CSS

html5\:section, #element-id, .element-class {
    ...
}

No, it isn't possible. 不,不可能。 That is why the JS shim is used. 这就是为什么使用JS垫片的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM