HTML5 not rendering header tags in IE

為{幸葍}努か 提交于 2019-12-01 21:40:13

In addition to my comment above, you don't need the html5shiv for IE9, which I'm sure you know.

Chances are there are some HTML problems elsewhere as IE doesn't try and fix things for you the way other browsers do.

The reason that <!--[if lt IE ]> <![endif]--> doesn't work is that you need to remove the lt so that it simply reads <!--[if IE]> <![endif]-->

Based on your reply above regarding the JS file, I'd try:

<!--[if lte IE 9]><script src="js/html5shiv.js"></script> <![endif]-->

And

<!--[if IE]><script src="html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]-->

is wrong. You need to have the http:// in front of the html5shiv.

A link to the website in question would be ideal.

UPDATE I see what's wrong now, you're missing a doctype! Add:

<!doctype html>

to the top of the file and it will be fine.

If no doctype is specified, IE always resorts to Quirks mode (which you never want!)

You also have multiple <head> elements which is wrong. And everything needs to be enclosed in a <html> element.

Actually there's a lot wrong with the markup, you don't even have a <body> element!

If fact, simply create the elements without even add it to the DOM will allow IE (even 6) to recognize it. So

<script type="text/javascript">
   document.createElement("'header'");
   document.createElement("'nav'");
   document.createElement("'article'");
   document.createElement("'section'");
   document.createElement("'footer'");
 </script>

will solve your problem. You can reduce it to

'article aside footer header nav section time'.replace(/\w+/g,function(n){document.createElement(n)})

found here: http://www.hagenburger.net/BLOG/Simple-HTML5-Fix-for-IE.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!