你可让一些较早的浏览器(不支持HTML5)支持 HTML5。html
现代的浏览器都支持 HTML5。html5
此外,全部浏览器,包括旧的和最新的,对没法识别的元素会做为内联元素自动处理。api
正由于如此,你能够 "教会" 浏览器处理 "未知" 的 HTML 元素。(也就是html5的新元素)浏览器
HTML5 定了 8 个新的 HTML 语义(semantic) 元素。全部这些元素都是 块级 元素。app
为了能让旧版本的浏览器正确显示这些元素,你能够设置 CSS 的 display 属性值为 block:dom
实例
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 新元素时须要先加载该文件。