views:

811

answers:

11

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.

+1  A: 

Could you try adding list-style-type: none; to #contact-list? Perhaps even instead of your list-style: declaration.

Eric Wendelin
No dice there. I tried removing that declaration too, but it doesn't seem to make a difference.
Dustman
+1  A: 

I would suggest doing it slightly differently, in the CSS - i.e.:

#contact_list
{
  list-style: none;
}

#contact_list li {
  padding-left: 20px; /* assumes the icons are 16px */
}

#contact_list #phone
{
  background: url(images/small_wood_phone.png) no-repeat top left;
}

#contact_list #i18l_phone
{
  background: url(images/i18l_wood_phone.png) no-repeat top left;
}
Remy Sharp
A: 
#contact_list
{
    list-style: disc none inside;
}

#contact_list #phone
{
    background-image: url(images/small_wood_phone.png) no-repeat top left;
    padding-left: <image width>px;
}

#contact_list #i18l_phone
{
    background-image: url(images/i18l_wood_phone.png) no-repeat top left;
    padding-left: <image width>px;
}
Marius
+5  A: 
#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);
}
Anne Porosoff
Nope, no good. Short and to the point, though. Thanks! :)
Dustman
The only other thing I can think might be an issue is if your styles are in a styles folder on the root and your images are in another folder. In which case you need to set your image paths to /images/small_wood_phone.png, for example.
Anne Porosoff
How many list items have the id="phone" and id="i18l_phone"? If there's more than one of each I would highly recommend using classes instead.
Anne Porosoff
+3  A: 

The thing is, I tried your code it it works. The only time it doesn't is if the images are not present. Maybe you need to check to see that the images you specify in the CSS are actually in the folder images or not misspelled.

NOTE: IN both firefox and ie.

Vincent Ramdhanie
+2  A: 

You might double check that those images are where you think they are. This example works fine unless the images are missing.

Hugoware
+5  A: 

I'm not sure if this is your problem, but you're using relative links to your images. When you use relative links in css, it is relative to the css file, but if it is inlined, it will be relative to the html page.

Russell Leggett
This is the almost certainly the actual answer, especially given Dustman's answer-response: http://stackoverflow.com/questions/209980/how-can-i-give-each-li-its-own-bullet-image/210232#210232
David Kolar
+1  A: 

It pains me to suggest it, but have you tried the !important flag? Also, does it behave the same in other browsers? What if this is something you have in your Firefox userChrome.css file?

Eric Wendelin
Good thought, but, no Safari/Opera/IE do the same thing. Well, IE doesn't, it thoroughly borks the padding and margins, but that is a whole different story...
Dustman
Man that's really odd that !important wouldn't fix your style overridden problem. Thinking...
Eric Wendelin
A: 

You could try adding !important after the list-style-image property, which would prevent it from being overridden.

James Anderson
+2  A: 

I never would have thought. If I quote the url, like so:

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

it starts working. I unquote it, and it stops. WTF? That's not supposed to make a difference.

Thanks for your help, everyone.

Dustman
D'oh! I almost suggested that! Good work.
Eric Wendelin
it wasn't the quotes, its the fact that you started it with "/images" instead of just "images"
Russell Leggett
+2  A: 

First determine whether you are in "quirks" mode or not, because for many CSS properties it makes a difference.

Secondly, the W3c specifies that the URL should be in double quotes (although I don't use the quotes, either). Go with the spec to save yourself trouble down the line.

If you are specifying "strict" in your DOCTYPE, then the browser may require the double quotes, per the standard.

flamingLogos