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

mrx3
mrx3
8,742 Points

Where to change my font-size for my navigation bar in css?

I'm not sure if I need to make the font-size change in the .nav class, or the .nav a class. When I add the my font size to the .nav class, or the .nav a class it does change my font size, but I'm unsure of which one is the correct one. Are both okay to make font size changes, or should one be used over the other. My code is below, and thanks in advance for the help.

.nav { border: 1em solid #ccc; border-width: .1em 0; list-style: none; margin: 0; padding: 0; text-align: center; } .nav li { display: inline; } .nav a { display: inline-block; padding: .63em; text-decoration: none; }

Is this CSS from a theme or something you created from scratch?

3 Answers

Great. I personally would use the more specific ".nav a" selector. The reason is you you add other text to the nav later and want to resize it wouldn't affect your links too. But I guess it's personal preference really.

mrx3
mrx3
8,742 Points

You're right Adam. I plan on adding more text to the nav later, and expanding the site. It would make more sense to use the ".nav a" selector. Thanks again for the help Adam, much appreciated, and to Jonathan as well.

Anytime! Good luck! Feel free to follow on twitter as I post a few tips on there too. @Sacki2013

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

try selecting .nav. That way your anchor elements will inherit the same font size if it's wrapped inside your li tags as they should be. :)

mrx3
mrx3
8,742 Points

Adam this is something I made from scratch. I'm practicing the concepts I've learned so far on the site, it's kind of my resume site. Thanks Jonathan, and Adam for your help.