-
Fancy Unordered Lists (bullet points) using CSS
13
Have you ever wanted to add fancy bullet points to your unordered lists in your(x)HTML but never knew how? The truth is, it’s actually really easy to achieve. All you need to do is add a CSS class to your unordered list and then use your CSS to add your chosen image as the bullet points. In this post I’ll walk you through this step by step. First lets take a quick look at the list we’re going to be creating:- This is the first list item
- This is the second list item
- and this is the third list item
Step 1: Create your unordered list, ensuring you use a classname for the ul.
OK the first step is to create your unordered list as normal, and to specify a classname on the ul element. In this example i am using a class name of “tick-list” as I’ll be using a tick image for my bullet point. The HTML code should look something like this:-
-
<ul class="list-tick">
-
<li>This is the first list item</li>
-
<li>This is the second list item</li>
-
<li>and this is the third list item</li>
-
</ul>
Step 2: Add the CSS to specify your image to be used as a bullet point
With our HTML list in place we now need to use our CSS to control how it will look. The following CSS will remove the default margin and padding for both the ul and li elements, remove the standard unordered list bullet points, indent the list items using some padding on the left, and finally place your chosen image as a background in the padded are at the left of the list item. Your CSS for this particular list should look something like this:-
-
ul.list-tick {
-
margin: 0;
-
padding: 0;
-
}
-
ul.list-tick li {
-
margin: 0;
-
padding: 2px 0 2px 16px;
-
list-style: none;
-
background: url('../images/list_icons/tick1.jpg') no-repeat top left;
-
}
Step 3: Dont forget to add your bullet/tick image to your server where your CSS can find it.
Of course the above HTML and CSS will not work without the image you want to use actually being available, so make sure you have them available on your server where your CSS can find them – you’ll also want to make sure that your image(s) are scaled down appropriately prior to using them, I have scaled down my bullet images to 12px x 12px so they should fit nicely beside standard sized text.
Step 4: View your fancy new list
OK, with the first 3 steps now completed, you should be ready to view you fancy new unordered list with customized bullet points, like so:
- This is the first list item
- This is the second list item
- and this is the third list item
Step 5: Experiment with different images
You can add as many different customised list classes and images as you like to your website. Below are a few more examples:-
List with a ‘list-pin1′ CSS class- This is the first list item
- This is the second list item
- and this is the third list item
Another list with a ‘list-pin2′ CSS class
- This is the first list item
- This is the second list item
- and this is the third list item
List with a ‘list-cross’ CSS class
- This is the first list item
- This is the second list item
- and this is the third list item
List with a ‘list-note’ CSS class
- This is the first list item
- This is the second list item
- and this is the third list item
List with a ‘list-mark’ CSS class
- This is the first list item
- This is the second list item
- and this is the third list item
So, use your imagination, you can add bigger images if you’d like, you’ll probabally need uo use bigger li text though or more padding. Let me know if you come up with any stunning lists of your own.
Tags: bullets, css, HTML, lists
13 responses to “Fancy Unordered Lists (bullet points) using CSS” 
-
Many thanks for that, CSS always melts my brains with lists.
-
Cheers for the post. We’ve enjoyed reading it.
-
Richard November 15th, 2010 at 18:00
Nice article. I tweaked it a little to make it extensible:
.image-list { list-style:none; margin: 20px 0; }
.image-list li { padding: 2px 0 12px 30px; background: url(‘img/icons/tick.png’) no-repeat top left; } /* default */
.image-list li.tick { background: url(‘img/icons/tick.png’) no-repeat top left;} /* explicit option */
.image-list li.plus { background: url(‘img/icons/plus.png’) no-repeat top left;} /* plus icon */Now you can call it like:
This will show a tick icon
This will also show a tick icon
This will show a plus iconI personally like the top left alignment for bullets as it looks good for wraping text, just preference I think.
-
hehe, I have been apply yet some fancy bullets to my website. Cool! Thanks mate!
-
Thank you for this valuable post. It changed my idea.
-
Fellow co-worker refered me to this site. I didn’t know you could do that for Unordered lists. Thanks Vince.
-
Kathy Hickey April 29th, 2009 at 17:09
How would I use bullets that look like a dash “-”. Do I need to create this as an image?
-
For the image background, you shouldn’t assign it to the top left corner of the background but to the middle using percentage values. Some images may not be a perfect square.
background: url(‘../images/list_icons/tick1.jpg’) no-repeat 50% 0;
Hypermiling August 22nd, 2011 at 22:39