The Wayback Machine - https://web.archive.org/web/20250110224019/https://www.geeksforgeeks.org/css-list-style-property/
Open In App

CSS list-style Property

Last Updated : 27 Aug, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

The list-style property in CSS is used to set the list style. the CSS list-style property is a shorthand for setting the list-style-type, list-style-position, and list-style-image properties in one declaration. It defines the appearance of list item markers, including their type (e.g., disc, circle), position, and custom images.

Syntax

list-style: list-style-type list-style-position list-style-image|initial|inherit;

Property Values

Name

Description

list-style-type:

This value sets a list item element’s marker (such as a disc, character, or custom counter style). Its default value is a disc.

list-style-position

This value sets the position of the marker relative to a list item. Its default value is “outside”.

list-style-image

This value sets an image to be used as the list item marker. Its default value is “none”.

We will understand the concepts of list-style property through the examples.

Methods to Use CSS List Style Property

1. Using list-style property value as Square

The CSS list-style property set to square renders square bullets for unordered lists (<ul>). It replaces default bullets with filled squares, enhancing visual presentation and list item differentiation on web pages.

Example 1: This example illustrates the use of the list-style property where the position value is set to inside.

HTML
<!DOCTYPE html>
<html>

<head>
    <title> CSS list-style Property </title>
    <style>
        ul {
            list-style: square inside url(
"https://write.geeksforgeeks.org/wp-content/uploads/listitem-1.png");
        }
    </style>
</head>

<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>
        CSS list-style Property
    </h2>

    <p>Sorting Algorithms</p>

    <ul>
        <li>Bubble Sort</li>
        <li>Selection Sort</li>
        <li>Merge Sort</li>
    </ul>
</body>

</html>

Output:

liststyle

2. Using list-style property value as Square Outside

The CSS list-style property, set to square outside, places square bullets outside the list items in unordered lists (`<ul>`). This creates a clean and structured appearance with bullets neatly aligned outside list content.

Example 2: This example illustrates the use of the list-style property where the position value is set to outside.

HTML
<!DOCTYPE html>
<html>

<head>
    <title> CSS list-style Property </title>
    <style>
        ul {
            list-style: square outside;
        }
    </style>
</head>

<body>
    <h1 style="color:green;">
        GeeksforGeeks
    </h1>
    <h2>
        CSS list-style Property
    </h2>

    <p>Sorting Algorithms</p>

    <ul>
        <li>Bubble Sort</li>
        <li>Selection Sort</li>
        <li>Merge Sort</li>
    </ul>
</body>

</html>

Output:

liststyle

Note: If no list-style-image is specified then it will be taken as none.

Supported Browsers

The browser supported by the list-style property are listed below:

CSS list-style Property – FAQs

What does the list-style property control?

The list-style property is a shorthand for setting the style, position, and image of list markers in one declaration for list items.

How can I remove list markers using list-style?

To remove list markers, you can use list-style: none;, which hides the bullet points or numbers for the list items.

Can I set different list styles for nested lists?

Yes, by targeting nested lists with specific selectors, you can apply different list styles using list-style properties like circle, square, decimal, or custom images.

Is list-style inheritable?

Yes, the list-style property is inherited, which means child list elements take on the style of their parent unless overridden.

Can list-style be combined with other properties like margin and padding?

Yes, list-style can be combined with margin and padding to control the spacing and alignment of list items more precisely.


Dive deep into the world of JavaScript with our JavaScript Full Course Online, offering everything from the basics to advanced techniques. Learn how to build interactive websites, optimize your code, and earn a certification to showcase your skills.

Take the Three 90 Challenge! Complete 90% of the course in 90 days, and earn a 90% refund. Push your limits and stay motivated as you work towards mastering JavaScript. Join now and get started on your JavaScript learning journey!


Next Article

Similar Reads

three90RightbarBannerImg