HTML DOM Style listStylePosition Property

HTMLWeb DevelopmentFront End Technology

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 −

raja
Published on 24-Oct-2019 11:08:51
Advertisements