CSS:
a:link { color: green;}
a:active {color: orange;}
HTML:
<a href="#">testing</a>
Here is JSFiddle
Pseudo-class :active still active after mouse button is clicked on the link, dragged away and released. How to make the link color return to normal after release the mouse button?
I'm using Firefox 14. It works fine in Chrome.
Pseudo class is to show different state of an element or a css selector. Active pseudo class is to show that the element is in active state. This pseudo class is mostly being associated with link and button or any other element which can be active. For example if it is associated with link that the link is active.
The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, "activation" typically starts when the user presses down the primary mouse button.
A link becomes active when you click on it. Tip: The :active selector can be used on all elements, not only links. Tip: Use the :link selector to style links to unvisited pages, the :visited selector to style links to visited pages, and the :hover selector to style links when you mouse over them.
The active class is applied to the navigation element the user is currently viewing. In the case of your given code, the user is viewing the the profile. It will serve as a guide or reminder to where in the website the visitor is in.
If you set your "active" colour on :focus:hover
it will have the closest effect to what you want, although it won't be exactly the same as in Chrome in that the colour you set will appear when the link is focused and hovered but not when the mouse button is down.
However, if the thing you dislike most is that the "active" colour remains after the mouse is released, you can at least prevent that from happening by setting your "normal" link colour on :focus
. The link does remain focused after it's been clicked, dragged off, and released - you can test this by doing it then pressing enter.
You may find examples (and information) on this page - note the link colours when you hold and release the mouse; they correspond to the a:hover
, a:focus
, a:focus:hover
, and a:active
rules for that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With