in Projects, Programming, Technology

CSS Link Color Sample Code

Here is the CSS required to change the color of a link in HTML. If you are trying to figure out how to use CSS to change link color, this is the code you’ll need. This can be used either inside the HTML of your page, or in a separate CSS file.

<style type="text/css">
a:link {
 color: #0000ff;
}
a:visited {
 color: #00ff00;
}
a:hover {
 color: #ff0000;
 text-decoration: none;
}
a:active {
 color: #777777;
}
</style>


Write a Comment

Comment

32 Comments

  1. this is great for all notepad lovers, but for those who use wysiwyg editor like dreamweaver there is such option already

  2. My wife is learning CSS right now. This one was bugging her all last night. I’ll point her in your direction

  3. Hey, it looks just like in the edit HTML section in Blogger. I never know it is so simple and easy to understand those lines. Now I remember, the color number is like the one I see in Photoshop.

  4. Hrm, I just picked this book up at the library, and I went on the internet to see if it was any good, and it was.

    Nice article!

  5. thanks for this. It really helps me modify my theme faster. It really helps. I hope that more articles like this will be available in your site. Thanks so much.

  6. Thanks for this simple tutorial. But can you give us more tutorial that can be useful for web designing… Im really into that lately. I am looking forward for more of your examples.

  7. I have known how to use this code before, the problem is that I kept on forgetting how to do it.. LOL.. So thank you for sharing this..

  8. Great, this is exactly what I was looking for. CSS is so useful and easy to use to create great looking and easy to maintain web pages. Cheers.

  9. hey this is great for all notepad lovers, but for those who use wysiwyg editor like dreamweaver there is such option already

  10. For some reason the link settings in CSS get mixed with my Explorer and Firefox automatic link settings. And when I set a color in CSS, then the Explorer or Firefox will still show a purple color link.

  11. Its a good way to make links on the website look more appealing.
    I know about hover only but now i know link active and visited.
    Thank you

  12. Is useful to learn the code. Many people now just use Dreamweaver etc… whilst they make life easier it’s not as good as learning the code yourself and using notepad!

  13. Yes, but.
    I have a link in white text on a black background. I want to modify that so that it goes yellow on hover. But on the same page I have another link in blue text on a white background. If I allow that to change to yellow on hover, it’s illegible. So I need to modify that one to go red on mouseover.
    How do I change one link differently to another?

  14. Thanks for the code. Really nice and simple. I was looking for the script and found just right here. Checked at the notebook.

  15. Link colors are puzzling me for 1 hour. I couldn’t make the unvisited link the required color. Now I know 🙂

    Thank you,
    John