Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I give each <li> its own bullet image?

Tags:

css

styling

I have tried

<ul id="contact_list">
    <li id="phone">Local 604-555-5555</li>
    <li id="i18l_phone">Toll-Free 1-800-555-5555</li>
</ul>

with

#contact_list
{
    list-style: disc none inside;
}

#contact_list #phone
{
    list-style-image: url(images/small_wood_phone.png);
}

#contact_list #i18l_phone
{
    list-style-image: url(images/i18l_wood_phone.png);
}

to no avail. Only a disc appears. If I want each individual list item to have it's own bullet, how can I accomplish this with css, without using background images.

Edit : I have discovered that, despite what firebug tells me, the list-style-image rule is being overridden somehow. If I inline the rule, like so:

    <li id="phone" style="list-style-image: url(images/small_wood_phone.png);">Local 604-555-5555</li>

then all is well. Since I have no other rules in the test case I'm running that contains ul or li in the selector, I'm not sure why inlining gives a different result.

like image 425
Dustman Avatar asked Oct 16 '08 19:10

Dustman


People also ask

How do I put an image in a Bullet in CSS?

Use list-style-image: url(imagename); to replace the bullets entirely with images. The downside of this method is that each browsers positions the images differently. CSS background images for list bullets is a more consistent method. Save this answer.

Can we use image as Bullet?

On the Home tab, in the Paragraph group, click the arrow next to Bullets, and then click Define New Bullet. In Word for Windows: Click Symbol or Picture, and then choose any symbol or picture that you want to use.

How do I change the Bullet icon in HTML?

Changing the Bullet to an Image There is another list style property available, list-style-image. When used it overrides the list-style-type value. It works like setting the background-image style. Use the url method, passing the url to the image you want as your bullets.


1 Answers

Try this:

#contact_list li
{
    list-style: none;
}

#contact_list li#phone
{
    list-style-image: url('images/small_wood_phone.png');
}

#contact_list li#i18l_phone
{
    list-style-image: url('images/i18l_wood_phone.png');
}
like image 184
Anne Porosoff Avatar answered Oct 04 '22 04:10

Anne Porosoff