1

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

2
  • 1
    it depends on many conditions... so it's hard to say Commented Apr 1, 2014 at 2:10
  • 2
    Excellent explanation: stackoverflow.com/questions/492809/… Commented Apr 1, 2014 at 2:11

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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 =/

Comments

1

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.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.