CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



list-style-position

The list-style-position property is used to specify the position of the marker (bullet, number, or image) in a list item. It is a part of the CSS box model and is used to control the layout and presentation of lists in web pages.

The list-style-position property can take two values:

  • inside: The marker is positioned inside the content box of the list item.
  • outside: The marker is positioned outside the content box of the list item.

By default, the value of list-style-position is outside.

Examples

Let's take a look at some examples to understand how the list-style-position property works:

Example 1: List with list-style-position: outside;

In this example, we have a list with the default value of list-style-position, which is outside:

  
    <ul>
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  
  • Item 1
  • Item 2
  • Item 3

As you can see, the markers are positioned outside the content box of the list item.

Example 2: List with list-style-position: inside;

In this example, we have the same list as before, but with the value of list-style-position set to inside:

  
    <ul style="list-style-position: inside;">
      <li>Item 1</li>
      <li>Item 2</li>
      <li>Item 3</li>
    </ul>
  
  • Item 1
  • Item 2
  • Item 3

As you can see, the markers are now positioned inside the content box of the list item.

Conclusion

The list-style-position property is a useful tool for controlling the layout and presentation of lists in web pages. By setting the value of this property to either inside or outside, you can control the position of the markers in your list items.

References

Activity