HTML5 浏览器支持(怎么样让低版本浏览器支持html5?)

你可以让一些较早的浏览器(不支持HTML5)支持 HTML5。

现代的浏览器都支持 HTML5。

此外,所有浏览器,包括旧的和最新的,对无法识别的元素会作为内联元素自动处理。

正因为如此,你可以 "教会" 浏览器处理 "未知" 的 HTML 元素。(也就是html5的新元素)

HTML5 定了 8 个新的 HTML 语义(semantic) 元素。所有这些元素都是 块级 元素。

为了能让旧版本的浏览器正确显示这些元素,你可以设置 CSS 的 display 属性值为 block:

实例

header, section, footer, aside, nav, main, article, figure {
    display: block; 
}
 
Internet Explorer 8 及更早 IE 版本的浏览器不支持以上的方式。
<!--[if lt IE 9]>
  <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]-->
以上代码是一个注释,作用是在 IE 浏览器的版本小于 IE9 时将读取 html5.js 文件,并解析它。
 
<!DOCTYPE html>
<html>

<head>
  <title>Styling HTML5</title>
  <!--[if lt IE 9]>
  <script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
  <![endif]-->
</head>

<body>

<h1>我的第一篇文章</h1>

<article>
London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.
</article>

</body>
</html>
 
html5shiv.js 引用代码必须放在 <head> 元素中,因为 IE 浏览器在解析 HTML5 新元素时需要先加载该文件。
posted @ 2016-04-07 15:53  友情管道工  阅读(332)  评论(0编辑  收藏  举报