tags:

views:

72

answers:

6

i wonder why i can't use, or should not use

a { ... }

vs

a:link, a:visited { ... }
+2  A: 

It's just a matter of it you want to have different styling for a visited link vs normal links or not (for example dim out the link, I was already there).

Just a is valid, but do you want to give :visited or :hover links special styling for example?

Nick Craver
i was thinking i can do `a { this will act as a default. will cover :visited, :hover, :active right } a:hover, a:active { styles specific to interactions like hover }`. so i dont have to have so much code, `a{}` vs `a:link, a:visited{}`
jiewmeng
A: 

:visited means you are trying to give a link a styling that has been visited by the user before and :hover means you are trying to give a link a style when a user mouse overs that link. You may or may not use it. This is your choice.

Gunner 4 Life
A: 

a:link if for an unvisited link, while a:visited is for a link that the user has visited. Usually the user will want some way to differentiate between the two in which case you'll style them separately. If you don't want any differences (e.g. a menu) then just a will do.

Andy
+4  A: 

If you only style a {...} then the style will also be applied to <a name="..."></a> tags, which are not really hyperlinks.

a:link {...} specifically relates to hyperlinks. :visited, :hover and :active are different states of these links. Note that :hover and :active can apply to other tags as well.

bluesmoon
remember, `<a …` does not mean ›link‹ it means ›anchor‹. `a:link` only applies to anchor elements with an href attribute
knittl
A: 

While the first a refers to all links, :link and :visited refers to specific states of those links.

The first one refer to non-visited links, and the latter to visited one. see http://www.w3.org/TR/CSS2/selector.html#link-pseudo-classes for more infos.

Alexis Métaireau
+3  A: 

You may provide the general style for your links with the a only. More specific styles can than be applied to the pseudo-classes. For example:

a {
    text-decoration: none;
    font-weight: bold;
}

a:link {
    color: #00F;
}

a:hover {
    color: #F00;
}

a:visited {
    color: #888;
}

a:active {
    color: #0F0;
}

In this example, all links are styled bold and are not underlined. But the color changes for each type of link...

faileN