html5shiv - 为什么只适用于IE? [英] html5shiv - why is it only for IE?

查看:94
本文介绍了html5shiv - 为什么只适用于IE?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想开始使用一些HTML5标签,但担心它将在不支持HTML5的浏览器上呈现。看起来html5shiv是我可以用于IE浏览器的解决方案< 9,然而,如果浏览器不支持HTML5而不是IE浏览器呢?然后怎样呢?为什么html5shiv是一个IE浏览器?

解决方案

首先,为了清楚起见,html5shiv只是让你可以设计HTML5标签(部分文章等)。它没有给予浏览器任何一般意义上的HTML5支持。



考虑到这一点,请注意,IE< 9是唯一的浏览器不允许HTML5标签的样式正确,所以这就是为什么html5shiv只适用于它们。



其他浏览器(即使是像Netscape Communicator 4这样非常古老的浏览器)仍然会解析无法识别的标签正确,并允许CSS应用到他们像你所期望的那样。



正如zzzzBov在他的回答中指出的,他们可能没有正确的默认样式(在大多数(所有?)个案都是 display:block 或没有任何内容),所以你甚至需要添加那些非老的IE浏览器。但是在非旧的IE浏览器中,这样做可以正常工作,而在oldIE中,添加这些默认样式---或任何样式 - 只有在使用html5shiv时才有效。


I want to start using some HTML5 tags, but worried how it will render on browsers that do not support HTML5. It seems like html5shiv is a solution I can use for IE browsers < 9.

However, what if the browser doesn't support HTML5 and is not IE? What then? Why is html5shiv an IE thing?

解决方案

First, to be clear, html5shiv just makes it so that you can style certain HTML5 tags (section, article, etc.) correctly. It does not give the browser "HTML5 support" in any more general sense of the term.

With that in mind, note that IE <9 are the only browsers that don't allow styling of these HTML5 tags correctly, so that's why html5shiv only applies to them.

Other browsers (even very old ones like Netscape Communicator 4) will still parse the unrecognized tags correctly and allow CSS to apply to them as you would expect.

As zzzzBov notes in his answer, they might not have the correct default styles (which in most (all?) cases are either display: block or nothing), so you'd need to add those even for non-oldIE browsers. But doing so works fine in non-oldIE browsers, whereas in oldIE, adding these default styles---or any styles whatsoever---only works if you use html5shiv.

这篇关于html5shiv - 为什么只适用于IE?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆