/

HTML / CSS / JavaScript Tutorial

CSS Property: list-style-position

[this page | pdf | back links]

The CSS (CSS1) list-style-position property identifies whether a list marker (e.g. a bullet character or (a), (b), (c) etc.) is inside or outside the relevant content container.

 

Valid property values (other than inherit and initial) are:

 

Value

Description

inside

Marker and text are indented and appear inside the relevant content container

outside

(default value). Marker is kept outside the relevant content container

 

Default Value:

outside

JavaScript syntax:

e.g. object.style.listStylePosition="inside"

Inherited:

Yes

Animatable:

No

 

EXAMPLE:


HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
div {width: 50px; border: 1px dotted black;}
.x1 {list-style-position: inside;}
</style>
</head>
<body>
Element with default property<br>
<ul><li>x1</li><li>x2</li></ul>
Property set using in-file HTML style<br>
<ul class="x1"><li >x1</li><li>x2</li></ul>
Property set using JavaScript<br>
<ul id="x2"><li>x1</li><li>x2</li></ul>

<script>
document.getElementById("x2").style.listStylePosition = "inside";
</script>

</body>
</html>

FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyListStylePosition() {
  var x = document.createElement("DIV"); x.style.listStylePosition = "inside"; return (window.getComputedStyle(x, null).listStylePosition == "inside");
}


NAVIGATION LINKS
Contents | Prev | Next | CSS Properties


Desktop view | Switch to Mobile