Jean is an Internet and Multimedia specialist with a keen interest in music, technology, business, sports and psychology.
Jean Galea
Internet Consultant in Malta
Jean Galea: entrepreneur and internet specialist. Holding an M.Sc. in Multimedia & Internet Computing from Loughborough University, Jean specialises in web design and development, email marketing systems and general internet consultancy.
When to use HTML IMG tags vs. CSS background-image

- Image via Wikipedia
Including an image on an HTML page can be done using either the HTML img tag or using the CSS background-image property. Having understood that, the next question is when to use which of these two methods.
From a semantics point of view we can say that the img tag should be used whenever the image is directly related to the content being explained on the page. Thus if I am showing a cooking recipe and want to display a photo of the finished plate, that would be directly related to the content and thus an tag would be in order. If on the other hand I want to display an image as part of the site’s design or for decoration purposes, it would be ideal to use the CSS background-image property.
Some other considerations to keep in mind are outlined in the following list of recommended uses for each method.
HTML img tag:
- Use
IMGif you intend to have people print your page and you want the image to be included by default. - Use
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. - Use
IMGif you rely on browser scaling to render an image in proportion to text size. - Use
IMGfor multiple overlay images in IE6. - Use
IMGwith az-indexin order to stretch a background image to fill its entire window. - Using
imginstead ofbackground-imagecan dramatically improve performance of animations over a background.
CSS background-image property:
- Use CSS background images if the image is not part of the content.
- Use CSS background images when doing image-replacement of text eg. paragraphs/headers.
- Use
background-imageif you intend to have people print your page and you do not want the image to be included by default. - Use
background-imageif you need to improve download times, as with CSS sprites. - Use
background-imageif you need for only a portion of the image to be visible, as with CSS sprites.

Related posts:
- The comprehensive tutorial for CSS-driven web menus
- How to automatically fix image orientation
- Image Replacement Techniques
- A Few Words on Accessibility
- Image maps in web design
Leave a Reply
Thank you for reading this blog. Please check back for new posts.

