Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

#nav ul vs. nav ul

Hello - I'm loving this course and I have a question on this video:

At around the 4:00 mark, instead of:

nav ul {
  list-style: none;
  margin: 0 10px;
  padding: 0;
}

could we add an id to the nav ul html and do this:

#nav ul {
  list-style: none;
  margin: 0 10px;
  padding: 0;
}

Or is it not possible because that attribute cannot be repeated on a single page?

Thank you!

3 Answers

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

a rule applied to the id or "#" will override a rule applied to the element itself or "nav" because of specificity... I think... I'm still pretty new to all this. But as I understand it, any rule applied to the "nav ul" will also be applied to any "nav ul" on any page connected to that particular css, but a rule applied to the more specific id or "#" will only apply to the particular element bearing that particular id.

Hope that helps.

But a inline style is only overwritten by !important.

Yes it's the same...

Thank you very much, Gentlemen, for your replies.

That explanation makes it clearer for me, Robert, thank you!

Robert Manolis
Robert Manolis
Treehouse Guest Teacher

My pleasure. Just glad I could help. :)