Note that there are some explanatory texts on larger screens.

plurals
  1. POCSS Trying to understand Alternate syntax when creating drop down list in CSS and HTML
    primarykey
    data
    text
    <p>I am seeing two different ways of referring to the unordered lists (<code>&lt;ul&gt;</code>), list items (<code>&lt;li&gt;</code>) and anchors (<code>&lt;a&gt;</code>).</p> <p>I want to set the attributes of these items in a drop down list with at least two levels of nested <code>&lt;ul&gt;</code>. </p> <p>My question is specifically about the ways to refer to the different levels of <code>&lt;ul&gt;</code>, <code>&lt;li&gt;</code> and <code>&lt;a&gt;</code> there in. </p> <p>I have named the navigation bar <code>id="navBar"</code>.</p> <p>I have seen on youtube: <a href="http://www.youtube.com/watch?v=T7ayE5AtRUA" rel="nofollow">Building a drop down navigation bar</a></p> <p>The syntax used is:</p> <pre><code>ul#navBar .sub1 li ul#navBar .sub1 li a </code></pre> <p>Where the class "<em>.sub1</em>" has been defined, and is the first level of <em>nested</em> <code>&lt;ul&gt;</code>, and "<em>.sub2</em>" is the second level of nested <code>&lt;ul&gt;</code>. </p> <p>Referencing these levels, the code used is.</p> <pre><code>ul#navBar .sub2 a { background-color: blue;} ul#navBar li:hover &gt; a { background-color: #CFC; } </code></pre> <p>It seems to me, that going to the bother of defining <em>.sub1</em> and <em>.sub2</em> is superfluous, and I have been using the format:</p> <pre><code>#navBar ul li{ background-color: blue;} #navBar ul li:hover ul{ background-color: red;} </code></pre> <p>REAL QUESTION:</p> <p>What is the correct syntax, using my (code just above) style of formatting. To refer to a second level nested <code>&lt;ul&gt;</code> and affect the <code>&lt;li&gt;</code> or the <code>&lt;a&gt;</code> there in?</p> <p>I assumed it was along the lines of:</p> <pre><code> #navBar ul li ul li: hover ul{ background-color: red;} </code></pre> <p>But I am wrong :(</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.
 

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