Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML

How do you override the default link colors?

By Jennifer Kyrnin, About.com

Question: How do you override the default link colors?

Answer:

All Web browsers have default colors they use for links if the Web designer doesn't set them. They are:

  • The default link color.
  • The active link color (when the mouse is clicked and held over the link).
  • The followed link color (when the link was clicked previously).

Plus, while most Web browsers don't change this by default, you can also define the hover color - the color the link is when a mouse is held over it.

Use CSS to Change Link Colors

To change these colors, you use CSS (there are some deprecated HTML attributes you can use as well, but I don't recommend using anything deprecated). The easiest way to change the link color is to style the <a> tag:

a { color: black; }

With this CSS, some browsers will change all aspects of the link (active, followed, and hover) to black, while others will only change the default color.

Use CSS Pseudo-classes to Change All Parts of a Link

A pseudo-class is represented in CSS with a colon (:) before the class name. There are four pseudo-classes that affect links:

To change the default link color:

a:link { color: red; }

To change the active color:

a:active { color: blue; }

To change the followed link color:

a:visited { color: purple; }

To change the mouse over color:

a:hover { color: green; }

More Web Design / HTML Q&A

Explore Web Design / HTML

About.com Special Features

Web Design / HTML

  1. Home
  2. Computing & Technology
  3. Web Design / HTML
  4. HTML and XHTML
  5. XHTML
  6. HTML Tags
  7. How do you override the default link colors - Links, Active links, Hovers, Followed links

©2009 About.com, a part of The New York Times Company.

All rights reserved.