user1638055
user1638055

Reputation: 492

CSS: Align image next to text in a list item?

I have a numbered list, like this:

<ol>
    <li>some text <img src="..." /></li>
</ol>

The image right of the text is below the text, not right of it. I tried a span and float:left, but this did not work. How could I align the image right of the text?

Thanks!

Upvotes: 0

Views: 3947

Answers (1)

Abdul Malik
Abdul Malik

Reputation: 2642

use floating for the text and the image and specify the width of the image and text divs for example

<ol>
 <li>
   <div style="float:left;width:200px;" >your text here..</div>
   <div style="float:right;width:100px;"><img src="abc.jpg" /></div>
   <div style="clear:both;"></div>
 </li>

assume that your li width is minimum 300px

Upvotes: 1

Related Questions