10 Simple CSS Code Examples You Can Learn in 10 Minutes

3. Change Link Colors

Let’s try changing the style of something other than a full paragraph. There are four different colors a link can be assigned: its standard color, its visited color, its hover color, and its active color (which it displays while you’re clicking on it). Here’s how we might change those: computer science computer science computer science computer science computer science computer science

a:link {
  color: gray;
}

a:visited {
  color: green;
}

a:hover {
  color: rebeccapurple;
}

a:active {
  color: teal;
}

Note that each “a” is followed by a colon, not a dot.

Each one of those declarations changes the color of a link in a specific context. There’s no need to change the class of a link to get it to change color. It will all be determined by the user and the state of the link.

4. Remove Link Underlines

While underlined text pretty clearly indicates a link, it sometimes looks nicer to scrap that underline. This is accomplished with the “text-decoration” attribute. Here’s how we’d get rid of underlines on links: computer science computer science computer science computer science computer science computer science

a {
  text-decoration: none;
}

Anything with the link (“a”) tag will remain un-underlined. Want to underline it when the user hovers over it? Just add this below:

a:hover {
  text-decoration: underline;
}

You could also add this text-decoration to active links to make sure the underline doesn’t disappear when the link is clicked computer science computer science computer science computer science computer science computer science

Prev2 of 6Next

Leave a Reply

Your email address will not be published. Required fields are marked *