Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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. :)