View Full Version : Background vs Img?

05-15-2008, 08:40 PM
Is there any benefit to using css background: url(); over <img> elements and vice versa?

05-15-2008, 08:53 PM
I believe if you have an image in a css file, once the CSS file loads it will load all images, that way during navigation i believe the user wont wait as much. Where as an img in html, it loads at every page.

Mr J
05-15-2008, 09:00 PM
When an image is used as background the content is automatically placed over it.

To get the same effect using an image tag you would have to place the content in a div and position the content over the image

05-15-2008, 09:21 PM
Background-image should only be used for images not conveying any information (decoration's images).

If the image vehicle information it must be placed in the (x)html with the img element to provide the alternative text in case of the image's not visible (text browser, loading problem, ...).

05-15-2008, 10:30 PM
What Candygirl said.

If the image is just eye candy or structural, use a background image through CSS.

If the image is something important, ie trying to convey information to the user, use the <img> with the alt attribute.