Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h2>IE7-8 Support</h2> <p>You were using <code>:nth-child</code> to begin with, which is not supported in those browsers, so I can see why those who answered did not care about support, as it would have appeared that you did not care about such support. However, selectors can be made to work for those. Using the adjacent sibling combinator <code>+</code> with the <code>:first-child</code> in key points creates the same effect as <code>:nth-child(2)</code></p> <p><a href="http://jsfiddle.net/JDp3j/2/" rel="nofollow"><strong>See Fiddle.</strong></a></p> <pre><code>ul li:first-child &gt; ul li:first-child {background: yellow;} ul li:first-child &gt; ul li + li {background: red;} ul li:first-child + li &gt; ul li:first-child {background: green;} ul li:first-child + li &gt; ul li + li {background: blue;} </code></pre> <h2>IE6</h2> <p><strong>You cannot get IE6 support</strong> without either javascript or directly putting classes on each of the <code>li</code> elements, as IE6 does not support <code>:first-child</code> or <code>+</code>. Personally, for color variations, you should just let IE6 go. If you insist, and do not want to use javascript to get selector function through that, then you are resolved to change the html:</p> <pre><code>&lt;div id="nav"&gt; &lt;ul&gt; &lt;li&gt;link 1 &lt;ul&gt; &lt;li class="one"&gt;SUB link 1&lt;/li&gt; &lt;li class="two"&gt;SUB link 2&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;li&gt;link 2 &lt;ul&gt; &lt;li class="three"&gt;SUB link 3&lt;/li&gt; &lt;li class="four"&gt;SUB link 4&lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt; </code></pre> <p>With this</p> <pre><code>.one {background: yellow;} .two {background: red;} .three {background: green;} .four {background: blue;} </code></pre> <p>Of course, that would work on <em>any</em> browser supporting css. But that is also <em>not</em> what I suspect you want to do. So again, leave IE6 to itself and forget about accommodating the color change on that or use javascript (perhaps through <a href="http://modernizr.com/" rel="nofollow">Modernizr</a>, <a href="http://jquery.com/" rel="nofollow">Jquery</a>, <a href="http://mootools.net/" rel="nofollow">MooTools</a>, etc.) to do it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload