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 trialNatalia C.
2,027 PointsWhat's the usage of the ':link' pseudo-class?
I'm not sure I'm getting this.
I'm already familiar with :visited & :hover pseudo-classes.
But I can't understand when and why we should use the :link
I mean yes, I can understand that it refers to UNvisited links. But I still can't get the point.
If we style 'a' elements to over-write the default blue color etc, let's say to:
a {
text-decoration: none;
color: green;
}
And we want the visited links to over-write the default purple, let's say to:
a:visited {
text-decoration: none;
font-weight: 800;
color: red;
}
We have what we want. Unvisited links will get their styling from 'a', and visited from 'a:visited'.
What exactly is the point of ':link' ???
When should we use it & why?
:/
(thanks in advance! hope I'm making sense.....)
2 Answers
Anna Dadej
10,707 PointsHi,
a:link applies only to anchor tags that have a href=" " attribiute, not a name=" " . But in HTML5 a name=" " attribute is no longer supported and the a tag is always a hyperlink or placeholder for a hyperlink, so you don't have to bother :)
Martynas Bucinskas
4,429 PointsI'm not going to create a new thread for my question. I think it kinda fits this one.
So for example, I want to get one of these effects only on a SPECIFIC button, link on my webpage. Is there a certain combination to accomplish it?
huckleberry
14,636 PointsYou're talking about targeting only one thing so I'd say your best bet there is to just give that button an ID and then use that ID with one of these pseudo classes.
Natalia C.
2,027 PointsNatalia C.
2,027 PointsYou just answered another question of mine! :) After writing my first post, I went back to re-watch the video in case there was something I didn't pay much attention to the first time. And I noticed that Guil said that it matches a elements that have a 'href' attribute, so I started wondering in what universe won't we have a 'href' attribute!! hahahaha
Thanks!
So, it doesn't actually make a difference (today, with HTML5).