Dany Y Dany Y - 11 months ago 51
CSS Question

How to put an image in div with CSS?

I would like to have all my images in CSS (the only way I know how is to put them in as background images).

But the problem in this solution is you can never let the div take the size of the image.

So my question is: what is the best way to have the equivalent of

<div><img src="..." /></div>
in CSS?

Answer Source

This answer by Jaap :

<div class="image"></div>​

and in CSS :

div.image {

you can try it on this link : http://jsfiddle.net/XAh2d/

this is a link about css content http://css-tricks.com/css-content/

This has been tested on Chrome, firefox and Safari. (I'm on a mac, so if someone has the result on IE, tell me to add it)