HTML Element Style How to - Remove underline from a link and add underline on hover








Question

We would like to know how to remove underline from a link and add underline on hover.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
a {<!--from  ww w.  j av a2s. c o m-->
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}
</style>
</head>
<body>
  <a href="#">Login</a>
</body>
</html>

The code above is rendered as follows: