HTML Link Color

How to change HTML link color.

Link text color

Changing link color is done with css styling:

<a href="../html-link.htm" style="color:red">Main page</a>

The code will generate this link:

Main page

Link background color

Changing link background color is done with css styling:

<a href="../html-link.htm" style="background-color:#ffffa0">Main page</a>

The code will generate this link:

Main page

Div links color

CSS code:

<style>
    #link_bar a { padding:15px; font-weight:bold; float:left; }
    #link_bar a:link { color:#d0d0d0; background-color:#0000a0; }
    #link_bar a:visited { color:#c0c0c0; background-color:#0000a0; }
    #link_bar a:hover { color:#ffffff; background-color:#000060; }
    #link_bar a:active { color:#f0f0f0; background-color:#00ff00; }
</style>

HTML code:

<div id="link_bar">
    <a href="html-anchor-link.htm">Anchor link</a>
    <a href="html-link-color.htm">Link color</a>
    <a href="../mailto.htm">Email link</a>
    <a href="html-image-link.htm">Image link</a>
    <a href="html-text-link.htm">Text link</a>
</div>

View:

 

 

 

#link_bar a is the style for all states of the link.

#link_bar a:link is the style of regular link.

#link_bar a:visited is the style of visited link.

#link_bar a:hover is the style of mouse hovered link.

#link_bar a:active is the style of link when pressed by the mouse.

 


See also

Write how to improve this page

HTML LINKS
RAPID TABLES