list-style-position

CSS list-style-position Property

The list-style-position property specifies whether a list item’s marker should be inside or outside the list-item box.

The list-style-position property is applied to list items and elements for which the display is set to “list-item”. By default, this includes <li> elements. It can also be set on parent elements: <ol> or <ul>.

类目类目
Initial Valueoutside
Applies toList items.
InheritedYes.
AnimatableNo.
VersionCSS1
DOM Syntaxobject.style.listStylePosition = “inside”;

Syntax

Syntax

list-style-position: inside | outside | initial | inherit;

Example of the list-style-position property with the “inside” value:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .inside {
        list-style-position: inside;
      }
      li {
        border: 1px solid #666;
        padding: 5px;
      }
    </style>
  </head>
  <body>
    <h2>List-style-position property example</h2>
    <p>Here the list-style is positioned "inside".</p>
    <ul class="inside">
      <li>List item 1</li>
      <li>List item 2</li>
      <li>List item 3</li>
    </ul>
  </body>
</html>

Result

In the given example the list items are positioned inside the box.

Example of the list-style-position property with the “outside” value:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      .outside {
        list-style-position: outside;
      }
      li {
        border: 1px solid #666;
        padding: 5px;
        margin-bottom: 15px;
      }
    </style>
  </head>
  <body>
    <h2>List-style-position property example</h2>
    <p>Here the list-style is positioned "outside".</p>
    <ul class="outside">
      <li>List item 1</li>
      <li>List item 2</li>
      <li>List item 3</li>
    </ul>
  </body>
</html>

Values

Values

ValueDescriptionPlay it
outsidePuts marker box out of the principal black box. It is the default value of this property.Play it »
insideSets the marker box as a first inline box in the principal black box.Play it »
initialMakes the property use its default value.Play it »
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部