Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color of an anchor when clicked

i want that when i click this link its color changes to the given color

<li id="press"><a href="<?=base_url()?>index.php/page/press">Press</a></li>
like image 467
richa Avatar asked Jan 22 '10 08:01

richa


People also ask

How do you change the color of an anchor?

To change the color of links in HTML, use the CSS property color. Use it with the style attribute. The style attribute specifies an inline style for an element. Use the style attribute with the CSS property color to change the link color.

How do I change the color of a link after clicking?

To change the color of hyperlink text, click Hyperlink, and then click More Colors. To change the color of the followed hyperlink text, click Followed Hyperlink, and then click More Colors.

How do you change the color of clicked?

Use HTML DOM Style backgroundColor Property to change the background color after clicking the button. This property is used to set the background-color of an element.


2 Answers

The CSS declaration :active will accomplish what you're after. http://www.w3schools.com/CSS/pr_pseudo_active.asp

Example.

a:active {
    color: #C00;
}

NB.

a:active MUST come after a:hover in the CSS definition in order to be effective!

like image 72
Jonny Haynes Avatar answered Nov 02 '22 05:11

Jonny Haynes


Here is the sample Css for the visited hyperlink

a:link {color:#FF0000}    
a:visited{color:Red}

Hope that will help.

like image 31
Asim Sajjad Avatar answered Nov 02 '22 04:11

Asim Sajjad