- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to add an image as the list-item marker in a list using CSS?
CSS, the acronym for cascading style sheets, is a straightforwardly built language that makes it easier to present web pages. Applying styles to web pages is possible with CSS. In this article we are going to see how we can use CSS to add an image as the list-item marker in a list.
Approach
We are going to make use of the list-style-image property to accomplish the task. The list-style-image property allows the user to set an image as the list-item marker in a list.
Syntax
list-style-image: none | url | initial | inherit;
Example
Step 1 − First we will define the HTML code.
<!DOCTYPE html> <html> <head> <title>How to add an image as the list-item marker in a list using CSS?</title> </head> <body> <h4>How to add an image as the list-item marker in a list using CSS?</h4> <div> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> </div> </body> </html>
Step 2 − Now we will add the CSS logic.
<style> ul{ list-style-image: url("https://www.tutorialspoint.com/images/logo.png"); padding-left: 350px; } </style>
Here is the complete code −
<!DOCTYPE html> <html> <head> <title>How to add an image as the list-item marker in a list using CSS?</title> <style> ul { list-style-image: url("https://www.tutorialspoint.com/images/logo.png"); padding-left: 350px; } </style> </head> <body> <h4>How to add an image as the list-item marker in a list using CSS?</h4> <div> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> </div> </body> </html>
Conclusion
In this article, we saw how with the help of the list-style-image property in CSS we could set an image as the list-item marker in a list.
Advertisements