HTML Element Style How to - Use image as list item bullet








Question

We would like to know how to use image as list item bullet.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
ul {<!--from  w w w . j ava  2 s  .co m-->
  list-style-type: none;
}

li {
  background: orange;
  width: 200px;
  height: 50px;
  margin: 0 0 20px 0;
}

.left-image {
  float: left;
  width: 60px;
  height: 60px;
  border: dashed 2px black;
  background: url(http://www.java2s.com/style/download.png) red;

}
</style>
</head>
<body>
  <ul>
    <li>
      <div class="left-image"></div> one
    </li>
    <li>
      <div class="left-image"></div> two
    </li>
    <li>
      <div class="left-image"></div> potato
    </li>
    <li>
      <div class="left-image"></div> four
    </li>
  </ul>
</body>
</html>

The code above is rendered as follows: