Page Widget How to - Format a menu block with hover background








Question

We would like to know how to format a menu block with hover background.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.menu {<!--from   w  w w  .  ja va  2  s . co m-->
  clear: both;
  height: 55px;
  background-color: #DDD;
}

.menu a {
  text-align: center;
  text-decoration: none;
  color: black;
  padding: 0 25px;
  line-height: 55px;
  display: inline-block;
}

.menu a:hover {
  background-color: #AAA;
}
</style>
</head>
<body>
  <div class="menu">
    <a href="#">About</a> 
    <a href="#">Item</a> 
    <a href="#">Product</a> 
    <a href="#">Blog</a> 
    <a href="#">Sale</a>
    <a href="#">HTML</a>
  </div>
</body>
</html>

The code above is rendered as follows: