让样式在 IE 中作用到未知的元素上——仅需 JS 创建此未知元素即可。
Hello World!
1
<html>
2
<head>
3![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<style>![](https://www.cnblogs.com/Images/dot.gif)
4![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
section {
}{ color: red; }</style>
5![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
<script>![](https://www.cnblogs.com/Images/dot.gif)
6
document.createElement("section")</script>
7
</head>
8
<body>
9
<section>Hello World!</section>
10
</body>
11
</html>
方便地使用HTML5元素
![](https://www.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif)
JS for HTML5
1 (function(){
2 // from:http://dean.edwards.name/weblog/2007/03/sniff/ if(!/*@cc_on!@*/0) return;
3 var html5= "abbr,article,aside,audio,bb,canvas,datagrid,datalist,details,dialog,eventsource,figure,footer,hgroup,header,mark,menu,meter,nav,output,progress,section,time,video".split(',');
4 for(var i = 0, len = html5.length; i < len; i++ ) {
5 document.createElement(html5[i]);
6 }
7 })();
Code 下载
HelloWorld.rar
参考资料
John Resig 《HTML5 Shiv》