Should I use the <img> tag or should I use a div with css background-image?
-
1it depends on many conditions... so it's hard to sayKing King– King King2014-04-01 02:10:19 +00:00Commented Apr 1, 2014 at 2:10
-
2Excellent explanation: stackoverflow.com/questions/492809/…pj013– pj0132014-04-01 02:11:48 +00:00Commented Apr 1, 2014 at 2:11
3 Answers
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.