HTML Element Style How to - Style anchor for hover and visited state








Question

We would like to know how to style anchor for hover and visited state.

Answer


<!--   w w w .  j  av  a  2 s  . com-->
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
a {
  font-weight: bold;
  color: #ff0000;
  text-decoration: none;
}

a:hover {
  color: #FF9900;
  text-decoration: underline;
  background-color: #f9f0f0;
}

a:visited {
  color: #990000;
}
</style>
</head>

<body>

  <a href="">A</a>
  <a href="">B</a>
  <a href="">C</a>

</body>
</html>

The code above is rendered as follows: