Html 页眉/页脚/导航标签 - 这些在 IE7、IE8 和不支持 HTML5 的浏览器中会发生什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5367526/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
header/footer/nav tags - what happens to these in IE7, IE8 and browsers than don't support HTML5?
提问by Martin
I am eager to start using Html5 in particular the <header>/<footer>/<article>/<nav>
tags.
我渴望开始使用 Html5,特别是<header>/<footer>/<article>/<nav>
标签。
What happens if the browser doesn't support these?
如果浏览器不支持这些会怎样?
Also I need to style these so: For Example: The nav
has borders and margins etc. You know standard CSS stuff.
我还需要这样设置样式:例如:nav
有边框和边距等。你知道标准的 CSS 东西。
So if I style them using the nav
tag then IE7 & IE8 etc are going to ignore this?
因此,如果我使用nav
标签设置它们的样式,那么 IE7 和 IE8 等会忽略这一点吗?
回答by Andrew Tubbs
Place this is the <head>
section of your page, before any CSS files are loaded.
<head>
在加载任何 CSS 文件之前,将此部分放在页面的部分。
<!--[if lte IE 8]>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script>
<![endif]-->
html5shi(m|v) creates doc elements for all the html5 elements so the styles from your CSS can kick in. Default behaviour for IE is to ignore unknown elements. For more info see resig's blog post.
html5shi(m|v) 为所有 html5 元素创建 doc 元素,以便 CSS 中的样式可以发挥作用。IE 的默认行为是忽略未知元素。有关更多信息,请参阅 resig 的博客文章。
回答by Rob
Yes, IE<9 will ignore any HTML5 elements (reason #3162 no one should ever have used IE) but there are javascript solutions for that which my groggy mind can't think of this morning. I'm sure others will post those solutions below. :)
是的,IE<9 会忽略任何 HTML5 元素(原因 #3162 没有人应该使用过 IE),但是有 javascript 解决方案可以解决我今天早上昏昏沉沉的头脑无法想到的问题。我相信其他人会在下面发布这些解决方案。:)