HTML Element Style How to - Create horizontal menu item from UL LI








Question

We would like to know how to create horizontal menu item from UL LI.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--  w  w w  .j  a  v  a  2s.c o  m-->
  list-style-type: none;
}

ul a {
  color: #000;
  text-decoration: none;
}

li {
  float: left;
  width: 150px;
  margin: 0px 10px 0px 0px;
  background: lightgrey;
  text-align: center;
}
</style>
</head>
<body>
  <ul>
    <li><a href="#">About</a></li>
    <li><a href="#">Loans</a></li>
    <li><a href="#">Blog</a></li>
    <li><a href="#">Users</a></li>
  </ul>
</body>
</html>

The code above is rendered as follows: