I'm having a problem using CSS's display:inline
property with the list-style-image:
property on <li>
tags. Basically, I want to output the following:
* Link 1 * Link 2
where *
represents an image.
I'm doing this with the following bit of HTML:
<ol class="widgets">
<li class="l1">Link 1</li>
<li class="l2">Link 2</li>
</ol>
which is styled with the following bit of CSS:
ol.widgets { list-style-type:none; }
ol.widgets li { display:inline;
margin-left:10px; }
ol.widgets li.l1 { list-style-image:url(image1.gif); }
ol.widgets li.l2 { list-style-image:url(image2.gif); }
The problem is that when the list items are displayed inline, the images associated with the list items do not appear. They do appear if I take out the display:inline
property on the <li>
tag.
Is there a way to make the images appear even when the list items are displayed inline, or is that just impossible?
The list-style-image CSS property sets an image to be used as the list item marker. It is often more convenient to use the shorthand list-style .
Firstly, you need to create the List Item using a li list item tag. Within that List Item tag, you can place your image. You add an image within the Image tag img. Hope this helps explain it a bit better.
The list-style-image property replaces the list-item marker with an image.
Try using float: left
(or right
) instead of display: inline
. Inline display replaces list-item display, which is what adds the bullet points.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With