PeaceDealer
PeaceDealer

Reputation: 1017

Style not being applied

I have an html menu, that start like this:

<nav id='main'>
<ul>

and my CSS file goes like this:

nav #main ul {
    list-style: none;
}

But for some reason, this does not seem to work... What am I doing wrong?

Upvotes: 2

Views: 91

Answers (4)

Andrea Ligios
Andrea Ligios

Reputation: 50193

Space is descendant selector.

You are trying to apply this style to:

  • All the <ul> descendants from an object with id="main" that is descendant of a <nav> object.

You should instead apply the style to:

  • All the <ul> descendants from a <nav> object with id="main".

It can be done removing the first space:

nav#main ul {
   list-style: none;
}

Upvotes: 6

petermk
petermk

Reputation: 777

it really should be

nav#main ul { }

Upvotes: 2

Manse
Manse

Reputation: 38147

Try using

nav#main ul {
  list-style: none;
}

ie remove the space between nav and #main - using the space is indicating #main is a descendant of nav instead of saying #main is an id attribute of nav

See the docs here for pattern matching in CSS2

Upvotes: 7

FarFigNewton
FarFigNewton

Reputation: 7273

Remove the space

nav#main ul {
   list-style: none;
}

Upvotes: 2

Related Questions