1 结论
HTML5支持所有的主流浏览器,如Chrome,火狐,Safari,IE9及以上的浏览器,但是不兼容IE8及以下的浏览器,IE8及以下的浏览器不能识别该标签,无法渲染样式,无法使用js操作
-
对于所有兼容的浏览器,不论新旧,都会自动把未识别元素当做行内元素来处理,可以设置:
header, section, footer, aside, nav, main, article, figure { display: block; }
-
对于IE8及以下的浏览器:
- 方法1:手动创建标签,同样需要使用
display:block
转换为块元素,document.createElement('article');
- 如果不添加这句话则不能为其设置样式或者通过js操作,并且这句话需要在dom加载前执行
- 方法2:引入第三方插件,下面的代码是一段注释,但是 IE9 的早期版本会读取它(并理解它)。
- 方法1:手动创建标签,同样需要使用
国内用户请使用百度静态资源库(Google 资源库在国内不稳定):
<!--[if lt IE 9]>
<script src="http://apps.bdimg.com/libs/html5shiv/3.7/html5shiv.min.js"></script>
<![endif]-->
原作者在googlecode上提供的地址:
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
2 ie8-兼容性解决细节:
2.1 方法1:document.createElement
document.createElement要放在dom加载之前执行
<!DOCTYPE html>
<html>
<head>
<title>Creating an HTML Element</title>
<script>
// 需要放在这里
// 兼容ie8-浏览器,如果不添加这句话,则不能为自定义标签设置样式
document.createElement("article")