HTML Element Style How to - Align list item horizontal, use | as the separator








Question

We would like to know how to align list item horizontal, use | as the separator.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
li {<!--from  w  ww  .  j  a v a2  s. c om-->
  display: inline;
}

li span {
  display: inline-block;
  margin: 0 5px 4px 5px
}

li a {
  color: #000;
  display: inline-block;
  line-height: 1.2em;
  border: 1px solid #EEE;
  padding: 3px 5px;
  text-decoration: none;
}
</style>
</head>
<body>
  <li><span>|</span><a href="">Help</a></li>
  <li><span>|</span><a href="">About</a></li>
  <li><span>|</span><a href="">Product</a></li>
</body>
</html>

The code above is rendered as follows: