HTML Element Style How to - Anchor:link, visited, hover, active








Question

We would like to know how to anchor:link, visited, hover, active.

Answer


<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of setting link styles</title>
<style type="text/css">
a:link {<!-- ww  w .ja v a 2s  .c  om-->
  color: #FF0000;
  text-decoration: none;
}

a:visited {
  color: #00FF00;
}

a:hover {
  color: #FF00FF;
  text-decoration: underline;
}

a:active {
  color: #0000FF;
}
</style>
</head>
<body>
  <p>
    <a href="http://www.java2s.com/" target="_top">Visit
      Tutorial</a>
  </p>
</body>
</html>

The code above is rendered as follows: