Javascript Reference - HTML DOM Style listStyleImage Property








The listStyleImage property sets or gets an image for the list item marker.

Browser Support

listStyleImage Yes Yes Yes Yes Yes

Syntax

Return the listStyleImage property:

var v = object.style.listStyleImage 

Set the listStyleImage property:

object.style.listStyleImage='none|url|initial|inherit'

Property Values

Value Description
none Default. No image.
url URL to load the image
initial Set to default value.
inherit Inherit from parent element.




Technical Details

Default Value: none
Return Value: A string representing the image location
CSS Version CSS1

Example

The following code shows how to set an image to the list-item marker.


<!DOCTYPE html>
<html>
<body>
<ul id="myList">
  <li>A</li>
  <li>B</li>
  <li>C</li>
  <li>D</li>
</ul><!--from   w w w. j  av a  2s.  com-->
<button type="button" onclick="myFunction()">test</button> 
<script>
function myFunction() {
    document.getElementById("myList").style.listStyleImage = "url('http://java2s.com/style/demo/border.png')";
}
</script>
</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get the list-style-image property.


<!DOCTYPE html>
<html>
<body>
<ul id="myList" style="list-style-image:url('http://java2s.com/style/demo/border.png');">
  <li>A</li>
  <li>B</li>
  <li>C</li>
  <li>D</li>
</ul><!--from   w  w w .  j av  a  2s  . c om-->

<button type="button" onclick="myFunction()">Return list-item marker</button>
 
<script>
function myFunction() {
    console.log(document.getElementById("myList").style.listStyleImage);
}
</script>

</body>
</html>

The code above is rendered as follows: