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



list-style-image

List-Style-Image is a CSS property that allows you to replace the standard bullet points or numbers in an ordered or unordered list with an image. This property is used to add a visual element to the list items, making them more attractive and engaging for the users.

The list-style-image property is used in conjunction with the list-style-type property, which sets the type of bullet point or numbering used in the list. When both properties are used together, the list-style-image property takes precedence over the list-style-type property.

Here are some examples of how to use the list-style-image property:

Example 1: Using a Custom Image

You can use a custom image as the bullet point for your list items by specifying the URL of the image in the list-style-image property. Here's an example:

<ul style="list-style-image: url('bullet.png')">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

In this example, we're using an unordered list (ul) and setting the list-style-image property to the URL of an image called "bullet.png". This will replace the default bullet point with the image.

Example 2: Using a Built-In Image

You can also use a built-in image as the bullet point for your list items by specifying the keyword for the image in the list-style-image property. Here are some examples:

<ul style="list-style-image: disc">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

In this example, we're using the "disc" keyword to set the bullet point to a filled circle.

<ol style="list-style-image: decimal">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ol>

In this example, we're using the "decimal" keyword to set the numbering to decimal numbers.

Example 3: Using Multiple Images

You can also use multiple images as the bullet points for your list items by specifying the URLs of the images in the list-style-image property. Here's an example:

<ul style="list-style-image: url('bullet1.png') url('bullet2.png')">
  <li>Item 1</li>
  <li>Item 2</li>
  <li>Item 3</li>
</ul>

In this example, we're using an unordered list (ul) and setting the list-style-image property to the URLs of two images, "bullet1.png" and "bullet2.png". This will alternate the bullet points between the two images.

Conclusion

The list-style-image property is a useful CSS property that allows you to add a visual element to your lists. By using custom images or built-in images, you can create unique and engaging lists that will capture the attention of your users.

References

Activity