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 trialMartin Awano
5,092 PointsWhat is the difference when you reference the "a" type selector vs the "a:link" pseudo-class in css?
If I want to get rid of text decoration, I could use either. What is the difference between the two and when should I use one vs the other?
2 Answers
David Clausen
11,403 Pointsa is a selector the element <a>.
:link is a pseudo selector that target elements that use href attribute that have not been visited...which is ONLY <a> for now.
So using a or :link is the same thing when it comes to applying.
But more to note is :link is for unvisited links. So its also a good readability that when someone reads your CSS they know you are explicitly targeting unvisited links.
thought :visit will override a too, so in the end the have similar effects.
Sara Chicazul
7,475 PointsAs David said, the :link pseudo selector is for unvisited links. Therefore, if you get rid of text-decoration under a visited, hovered, and active links will still be underlined. You would have to set text-decoration for each of those pseudo-classes if you wanted them all without underlines.
Use the a selector if you want to set properties for all links, regardless of state. Use the pseudo classes to override these defaults for a specific state.