Javascript Reference - HTML DOM Style listStylePosition Property








The listStylePosition property sets or gets the position of the list-item marker.

Browser Support

listStylePosition Yes Yes Yes Yes Yes

Syntax

Return the listStylePosition property:

var v = object.style.listStylePosition 

Set the listStylePosition property:

object.style.listStylePosition='outside|inside|initial|inherit'

Property Values

Value Description
outside Default. Put list-item marker before text content.
inside Indent the list-item marker
initial Set to default value.
inherit Inherit from parent element.




Technical Details

Default Value: outside 
Return Value: A string representing the list-item marker position
CSS Version CSS1

Example

The following code shows how to change the list-item marker position.


<!DOCTYPE html>
<html>
<head>
<style>
li {<!--from  w  w w.  ja v  a 2 s.c o m-->
    background-color: red;
}
</style>
</head>
<body>
<button onclick="myFunction()">test</button>
<ul id="myUL">
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>

<script>
function myFunction() {
    document.getElementById("myUL").style.listStylePosition = "inside";
}
</script>

</body>
</html>

The code above is rendered as follows:





Example 2

The following code shows how to get the list-item marker position.


<!DOCTYPE html>
<html>
<body>
<!-- w  w  w  . j  a  v  a 2  s  . c o  m-->
<ul id="myList" style="list-style-position:inside;">
  <li>A</li>
  <li>B</li>
  <li>C</li>
  <li>D</li>
</ul>
<button type="button" onclick="myFunction()">test</button> 
<script>
function myFunction() {
    console.log(document.getElementById("myList").style.listStylePosition);
}
</script>
</body>
</html>

The code above is rendered as follows: