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 trialOtto Mejia
744 PointsWhy do you need a pseudo class if the links don't change color?
I'm doing the exercise Customizing Colors and Fonts in the lessons of How to Make a Website, and the instructor is showing that a pseudo class is needed for the links in the navigation to not change color when they are clicked on. But when I click on the navigation pages it doesn't change color even if I don't put in the pseudo class. So why is it needed?
4 Answers
David Birnie
2,726 PointsA pseudo class is a way to 'id' a group of code as one so you can select them all at once. This is different from the 'id' because the you can only have one id in your HTML with the same name. When you add a class into your HTML you can select multiple sections of code that you named in the class...
For example if you wanted your tabs, and body to be the same color instead of changing them separate you can reduce the amount of code by adding both the tabs and body in a pseudo class in your HTML and then in CSS type your class tag to make the changes (color, font, etc). (for example if you called your class "1" and set the class for both the Body and Tabs when you recall "1" in your CSS your changes to the font would take affect to everything with the pseudo class "1")
Hope this made sense... I might not be the best at explaining.
David Birnie
2,726 PointsHard to say why it is needed in the particular problem with out knowing what problem you are referring to. If you are working through a track most likely if they have not already explained the reason behind it it will be reference for a future video.
chunlingzhou
596 PointsI have the same question as Otto Mejia... w/o adding in the pseudo class, the colors on the nav still didn't change color when get clicked on. Then why do we need to add the pseudo class in this program?
David Birnie
2,726 PointsI need to see your code that you are talking about.. hard to say when I dont have it in front of me
David Birnie
2,726 PointsI need to see your code that you are talking about.. hard to say when I dont have it in front of me
David Birnie
2,726 PointsI need to see your code that you are talking about.. hard to say when I dont have it in front of me
Lee Zamastil
21,628 PointsCorrect me if I'm wrong but I think some browsers (or some versions of browsers) automatically change the colors of the links. So if you don't specify in the CSS that the links should always remain the same color then it's possible that they might not.
If your browser didn't change the color of the visited links then perhaps another browser (or an older version of your browser) would change the color.
Otto Mejia
744 PointsOtto Mejia
744 PointsI know what pseudo classes are and how they work, I just want to know why the pseudo class is needed in this particular problem. I wanna know why is it needed to not change the navigation color if the colors on the navigation didn't change at all when hovered on or clicked on.