Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML How to Make a Website Customizing Colors and Fonts Use Color in CSS

How would I change the link background & the link text when the link is hovered & clicked?

I'm using Sublime Text 2 to work on another site while following along with the course. For now, the page background is BLACK, and the page text is RED. What I want is the link text to be RED before & after the link is clicked, the link background to be RED & link text to be BLACK when the link is hovered on, and for the link background to be WHITE & link text to be BLACK when the link is clicked.

body {
    color: #FF0000;
    background: #000;
}
a, a:visited {
    color: #FF0000;
}
a:hover {
    color: #000;
    background: #FF0000;
}
a:active {
    color: #000;
    text-decoration: none;
    background: #FFF;
}

Is there a simpler way write this, or is it how it should be?

1 Answer

Hi Christopher,

This seems pretty good to me, there isn't another way of going about it unless you start using more advanced methods like Sass but even then the same principles apply for this case just the code would look a little different.

You have it spot on really as it is :)

Craig

ok, thanks.