我们在实际开发过程中会为了确保所有新的HTML5元素能以block元素正确渲染,我们会定义:

header,footer,article,section,nav,menu,hgroup,aside{
   display:block;
}
 

但是IE会忽略这些样式,原因很简单,低版本的IE不识别这些标签,那我们咋做呢?

其实原理还是比较简单的!

document.createElement('header');

现在大家用的最多的是Remy Sharp写了HTML shiv,下面有在线的脚本链接,有兴趣的可以自己看看。

使用方法:

  1. 在html的文件的head部分
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js">
<![endif]-->
 

注释:

Common question: what's the difference between the html5shim and the html5shiv? Answer: nothing, one has an m and one has a v - that's it.

 HTML5 Shiv和HTML Shim官方给的说明是:

  nothing,one has an m and one has a v-that's it.

扩展阅读:

1、http://html5shiv.googlecode.com/svn/trunk/html5.js  shiv的在线脚本地址

2、http://html5shim.googlecode.com/svn/trunk/html5.js  shim的脚本脚本地址

3、http://ejohn.org/blog/html5-shiv/