0

To style the first level of a menu i would think this code would work:

http://jsfiddle.net/2g36L/1/

Could someone please point out where I'm going wrong, thanks.

Paul Mason
  • 1,818
  • 2
  • 20
  • 32

2 Answers2

3

It does, but since you've given no other color to the other elements they inherit the color you gave the top <ul> element. If you give the other <ul> a color, it works fine.

jsFiddle example.

j08691
  • 204,283
  • 31
  • 260
  • 272
  • +1 - Your solution is fine, but I would do it like this: `ul {}` for the first level and `ul > li > ul {}` for the second level. As in your style the second level gets the default style for all other `ul`s on the page. And also the hierarchy gets a little clearer. And yes, it's also in my example the case that the first level `ul` gets the default `ul`, but maybe this is useful or you could add a `div > […]` to both if applicable. – insertusernamehere Aug 15 '12 at 20:52
1

Color is an inherited CSS trait, so even though you are declaring it only for the immediate UL beneath the div, it is being inherited by the nested elements.

Mike Brant
  • 70,514
  • 10
  • 99
  • 103