HTML DOM Style listStylePosition Property


The HTML DOM Style listStylePosition property is used for setting or returning the list-item marker position.

Following is the syntax for −

Setting the listStylePosition property −

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

The above properties are explained as follows −

Value
Description
outside
Thisis the default value and place list-item marker before text.
inside
Thisindents the list item marker a little to the inside.
initial
Forsetting this property to initial value.
inherit
Toinherit the parent property value

Let us look at an example for the listStylePosition property −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
   li{
      background-color:lightgreen;
   }
</style>
<script>
   function changeListPosition() {
      document.getElementById("LIST1").style.listStylePosition = "inside";
      document.getElementById("Sample").innerHTML=" The list style position is now set to inside from    default outside.";
   }
</script>
</head>
<body>
   <ul id="LIST1">
      <li>LIST ITEM1</li>
      <li>LIST ITEM2</li>
      <li>LIST ITEM3</li>
      <li>LIST ITEM4</li>
   </ul>
   <p>Change above list style position by clicking the below button</p>
   <button type="button" onclick="changeListPosition()">Change List Position</button>
   <p id="Sample"></p>
</body>
</html>

Output

On clicking the “Change List Position” button −

Updated on: 24-Oct-2019

15 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements