HTML Element Style How to - Separate li item with two color border-right








Question

We would like to know how to separate li item with two color border-right.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
li {<!-- w ww  .j av  a 2s . com-->
  float: left;
  background: grey;
  padding: 5px;
  border-right: 1px solid red;
  position: relative;
}

li:after {
  content: "";
  position: absolute;
  z-index: 1;
  border-right: 1px solid black;
  display: block;
  top: 0%;
  right: 0%;
  height: 100%;
}

li a {
  color: white;
  text-decoration: none;
}
</style>
</head>
<body>
  <nav>
    <ul>
      <li><a href="">About</a></li>
      <li><a href="">Product</a></li>
      <li><a href="">Term</a></li>
      <li><a href="">Blog</a></li>
    </ul>
  </nav>
</body>
</html>

The code above is rendered as follows: