Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change link colour using CSS

Tags:

html

css

I'm playing with link colours and am struggling over one particular issue.

My CSS code is:

a:link {
  text-decoration: none;
  colour: white;
}

a:visited {
  text-decoration: none;
  color: purple;
}

a:hover {
  text-decoration: underline;
  color: #C0C0C0;
}

Everything is functioning perfectly, except that the default link colour isn't changing. The hover and visited colours are changing as per the commands, I can add or remove underlines from the default link style, I can change the colour of the default text background, and it all works just fine. It's just the text colour of the default link that I seem unable to manipulate. I have tried using just a: instead of a:link but that makes no difference. If I use the old

<body link="white">

technique then the default colour changes as required, but I need to do this in CSS.

Can anyone suggest why just this one function isn't working for me?

like image 937
user1806216 Avatar asked Nov 07 '12 13:11

user1806216


People also ask

Can you change the color of links in CSS?

As far as CSS color is concerned, links, or <a> tags, behave in the same way as regular text. This means to change the color of a link all you need to do is use the CSS color property on the anchor tag with whatever color Hex you want, in the example below we use red.

How do I change the color of a hyperlink in HTML CSS?

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 you change the color of a link?

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.

What color are links in CSS?

Default value of links:Normal/unvisited links are blue. Visited links a colored purple. Active links are colored red.


1 Answers

You have a typo:

colour: white;

Should be:

color: white;
like image 121
Oded Avatar answered Sep 19 '22 06:09

Oded