Page Widget How to - Decrease space between text and border








Question

We would like to know how to decrease space between text and border.

Answer


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

.border {
  position: relative;
}

.border:hover::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 0;
  left: 0;
  bottom: 4px;
  border-bottom: 2px solid #000;
}
</style>
</head>
<body>
  <a class="underline" href="#">underline</a>
  <a class="border" href="#">border</a>
</body>
</html>

The code above is rendered as follows: