0

I am trying to give style to my links and I am using this order:

a{}
a:visited{}
a:focus{}
a:hover{}
a:active{}

(I am not using a:link... I just use the id's to make the links work.)

The thing is that my "a" & "a:hover" are working but "a:visited" & "a:active" are not!!! Is there a solution? I am only tying to give different color to "a:active":

a:active{
 font-family: gabriola, verdana; font-size: 26px; color: #e6e8fa; text-decoration: none; vertical-align: middle; border: none; outline: none;
}
2
  • What exactly isn't working? See w3schools.com/css/tryit.asp?filename=trycss_link for an example. Your code seems to be correct. Commented Jul 22, 2011 at 16:42
  • a:active is not... because my "links" look like this <a id=goto"> Then I am retrieving the id and sent the user where I need to. "a" and "a:hover" are working. "a:active" not... And I think @Kerrek is right Commented Jul 22, 2011 at 16:57

2 Answers 2

2

I read somewhere (a quick Google suggests it could have been anywhere) that it's easy to remember the order for anchor styling declarations using the mnemonic L o V e / H A t e:

a:link
a:visited
a:hover
a:active
Sign up to request clarification or add additional context in comments.

Comments

1

active doesn't make sense for non-link anchors (not sure about this actually, :active might be triggered on any visible element). Use this:

a:link, a:visited               // normal links
a:link:hover, a:visited:hover   // link with mouse-over
a:link:active, a:visited:active // link being clicked (mouse-down, etc.)

Also available, but less specific:

a        // any anchor
a:hover  // any anchor with mouse-over

The latter two will have their properties overridden by the more specific ones above if the anchor actually has the href attribute set.

14 Comments

But using "a:link" I will have to add href="" to my anchors to work right?
Well, what do you want to style? a:link styles anchors with href, while a styles all anchors.
Oh, perhaps you can actually apply :active to all elements. I'm not sure if that's standardized behaviour, the spec only says "while an element is being activated by the user".
I want to style my anchor that works as a link, without including href... And as you 're saying I cannot do that for active links...?
@Pavlos1316 — in order to work as a link, you need an href attribute. That is how you create links.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.