Xiraa - Tech Forum

Full Version: Add image to left of text via css
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I add an image to some text via css?
I've got this:
Code:
<span class="create">Create something</span>
and I want to add a 16x16 image to the left of that by using css. Is this possible or should i just manually add this image like so:
Code:
<span class="create"><img src="somewhere"/>Create something</span>
I'd rather not have to manually change all of the places which is why I wanted to do it via css.
thanks!
Try Something like this:

Code:
.create{
background-image: url('somewhere.jpg');
background-repeat: no-repeat;
padding-left: 30px;  /* width of the image plus a little extra padding */
display: block;  /* may not need this, but I've found I do */
}

You might have to play around with padding and possibly margin until you get your desired result.