Change Color of Links
Have you ever wanted to change the color of links in a website, but ran into trouble? Our guide here serves to shed light on the process of changing the color of links using CSS or Cascading Style Sheets. The nature of all links are all styled in the same way on all websites. Links follow a hierarchy structure when it comes to CSS, and it is important to follow this order or the results may not be desirable.
To change color of links on your website, find the CSS style sheet and open it up. We are going to add the following piece of code that has to be added in the following order:
a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red;}
a:active {color: yellow;}
You can change the colors of the different actions easily by changing out the color names, preferably with hex codes.
The “link” CSS style is the base color of a link that has not taken any action yet. This must come first in the CSS style sheet. “Visited” is for links that the visitor has clicked on. This will help the visitor distinguish between links he or she has visited and those left to explore. Use this option sparingly. “Visited” must come second in the CSS style sheet line up.
Next is “hover” which is related to a hover over action of the mouse on top of the link. Changing the color to a more distinguishable, usually darker color makes good use of the “hover” CSS style selector. “Hover” must come third in the CSS style sheet line up.
Finally, is “active” is the state upon which the link has just been clicked on and is about to send the visitor to the requested location. Uses for this CSS selector can be bright colors that reward the user for clicking by satisfying their desire to have something occur when they tap on your link. “Active” must occur at the end of the CSS style sheet list of psuedo-classes.
BONUS:
For even better accessibility, add in the following piece of code in under the “hover” option to allow keyboard only users that are not using a mouse to see the same functionality as mouse users would when “hovering” or keying over to a selected link item.
a:focus {color: red;}
The full set of CSS pseudo-class code with the bonus is below:
a:link {color: blue;}
a:visited {color: purple;}
a:hover {color: red;}
a:focus {color: red;}
a:active {color: yellow;}
Have something to add to this article? Do so in the comments.
Leave a Reply
Want to join the discussion?Feel free to contribute!