Css child (>) selector not working in IE8?

From what I have compiled and understood here and there (stop me when I am wrong): the child selector (>) works on IE7 + while you run the standards mode with your doctype, html5 <!DOCTYPE html> should do this.

However, my css:

 nav > ul > li > a { padding: 0.2em 2em 0.2em 2em; background-color: #FAFAFA; } nav > ul > li > a:hover { background-color: #AFAFAF; } 

doesn't seem to reach my html:

 <!DOCTYPE html> ... <body> <header> <nav> <a class="inblock valignC logo" href="/"><img src="static/img/logo.gif" /></a> <!--Menu nav : LOGO | Agence | Portfolio | Equipe | Clients | Contact--> <ul class="inblock valignC"> <li class="inline"><a class="ie" href="/agence/">Agence</a></li> ... </ul> ... 

in IE8, I have to use a dedicated .ie class, which I added to target <a> s.

Any explanation?

+7
source share
4 answers

You need to use HTML5 Shiv for versions of IE under 9:

 <!--[if lt IE 9]> <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv.min.js"></script> <![endif]--> 
+11
source

Perhaps this is not a selector, but the tags themselves, since they are not defined as standard tags in IE8 and below. You can see if this is just by using ul > li and see if the selector works.

In fact, you can’t do anything except that you don’t use HTML5 tags until more people update their browsers. Personally, I would prefer to use <div class="nav"> .

+2
source

I think this is due to the fact that older browsers do not have a navigation element.

+1
source

This does not work because IE8 does not understand or "correctly" implement HTML tags such as <nav> .

Do not use HTML 5 until 2015. This is for two reasons:

  • The W3C recommendation for HTML5 was not finalized until December 2014, so any current browser version wonders what the final document will contain. The code that works now does not guarantee operation after this point (but probably will). Adding JS hacks at the top to make browsers compatible with HTML5 adds more potential compatibility issues.

  • By 2015, market share for IE8 is likely to be at minimal levels, for example. below 2-3%, in this case the benefits of IE8 support will be exceeded due to the cost of using HTML5 compatible code.

At the same time, it’s a good idea to use the HTML type of the document because it is advanced and backward compatible and uses a subset of HTML5 tags that are also valid in HTML4 (in other words, tags that are valid in HTML4 AND HTML5, which is most of them ) Personally, I like to use <div class="nav"></div> instead of <nav></nav> etc. Etc.

At the end of the day, do what you want, but you should be aware of these problems, at least especially in a world where HTML5 is a buzzword that is used frequently and inappropriately.

+1
source

All Articles