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 trialJoseph Lu
698 Pointswhy doesn't nav then use the property color change the text?
why can't i do
nav { color: value }
or
nav ul { color : value }
or
nav li { color: value }
change the text colors for the navigation but using the selector "a" changes all the color of the anchors?
5 Answers
Nick Yoho
6,957 PointsIf the items in your navigation are links you will have to set a rule for the anchor elements to change their color. You could target them directly like this
nav a {
color: #fff;
}
This would only change the links in the navigation to that color and no other links on the page. The code you have would target any text that is not a link in your navigation
Timo J.
Courses Plus Student 20,919 PointsHEllo Joseph
Show us your code plz?
Joseph Lu
698 Pointsa { text-decoration: none; }
wrapper {
max-width: 940px; margin: 0 auto; padding: 0 5%; }
logo {
text-align: center; margin: 0; }
a { color: #6ab47b; }
header { background: #6ab47b; border-color: #599a68;
}
h1, h2 { color: #fff;
}
nav { color: #fff; background:#599a68; }
Joseph Lu
698 Pointsi try to do nav { color:#fff; } or nav ul or nav li to change the color of the text , instead of nav a. however it seems that it doesn't work like that. i tested some cases, it seems that you have to put "a" as a decedent in order to change the text in the nav or strictly just use "a" as a selector to change the text.
Joseph Lu
698 Pointsi just wanna know why.
Joseph Lu
698 PointsJoseph Lu
698 Pointsi tested it. you are correct. thx for the help