In what situations is it more appropriate to use an HTML IMG tag to display an image, as opposed to a CSS background-image, and vice-versa?
Factors may include accessibility, browser support, dynamic content, or any kind of technical limits or usability principles.
Proper uses of IMG
IMGif you intend to havepeople print your page and you want the image to be included by default.
—JayTee
IMG(withalttext) when the image has an important semantic meaning, such as a warning icon. This ensures that the meaning of the image can be communicated in all user-agents, including screen readers.Pragmatic uses of IMG
IMGplus alt attribute if the imageis part of the content such as a logo or diagram or person (real person, not stock photo people).
—sanchothefat
IMGif you rely on browser scaling to render an image in proportion to text size.IMGfor multiple overlay images in IE6.
UseIMGwith az-indexin orderto stretch a background image to fill its entire window.
Note, this is no longer true with CSS3 background-size; see #6 below.
imginstead ofbackground-imagecan dramatically improve performance of animations over a background.When to use CSS background-image
image is not part of the content.
—sanchothefat
doing image-replacement of text eg. paragraphs/headers.
—sanchothefat
background-imageif you intend to havepeople print your page and you do not want the image to be included by default.
—JayTee
background-imageif you need to improve download times, aswith CSS sprites.
background-imageif you need for only a portion of the image to be visible, as with CSS sprites.background-imagewithbackground-size:coverin order to stretch a background image to fill its entire window.