Should I use the <img>
tag or should I use a div with css background-image
?

- 65
- 2
- 11
-
1it depends on many conditions... so it's hard to say – King King Apr 01 '14 at 02:10
-
2Excellent explanation: http://stackoverflow.com/questions/492809/when-to-use-img-vs-css-background-image – pj013 Apr 01 '14 at 02:11
3 Answers
If you want the image displayed normally on the page, then i would suggest using
img because it can moved positioned to your prefered area alot more accurately, but the background-image should only be used if you want the image to be the background of your page or of an object.

- 273
- 1
- 10
Well, is your image a background image? If so, then use background-image
. That is what it is made for, so you should use it.
If not, then use <img>
Background images usually have elements on top of them, such as text, for example.
Images are generally elements of their own, like blocks on the page, such as a <div>
for example.
Having said that, there are some "advantages" with using <img>
vs. background-image
. For example, background-image
will disable the users ability to drag and drop the image onto their desktop. This is not to say that they cannot save the image, they can, very easily, this is just one difference between the two.

- 1,615
- 18
- 26
If you need create a kind of tumbs you must use <img>
.And for background use background-image.
All browsers not interpreted the css rules in the same way.
Sorry for my english =/

- 113
- 1
- 4