Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-15-2008, 07:40 PM   PM User | #1
flynch01
Regular Coder

 
Join Date: Mar 2007
Location: England
Posts: 357
Thanks: 46
Thanked 22 Times in 21 Posts
flynch01 is on a distinguished road
Background vs Img?

Is there any benefit to using css background: url(); over <img> elements and vice versa?
flynch01 is offline   Reply With Quote
Old 05-15-2008, 07:53 PM   PM User | #2
jcdevelopment
Senior Coder

 
jcdevelopment's Avatar
 
Join Date: Oct 2007
Location: Cowboy Nation
Posts: 2,171
Thanks: 173
Thanked 257 Times in 257 Posts
jcdevelopment will become famous soon enoughjcdevelopment will become famous soon enough
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.
jcdevelopment is offline   Reply With Quote
Users who have thanked jcdevelopment for this post:
flynch01 (05-15-2008)
Old 05-15-2008, 08:00 PM   PM User | #3
Mr J
Senior Coder

 
Join Date: Aug 2002
Location: UK
Posts: 2,789
Thanks: 2
Thanked 14 Times in 14 Posts
Mr J is on a distinguished road
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
__________________
The silent one.

The most dangerous thing in the world is an idea.
The most dangerous person in the world is the one with an idea.
Mr J is offline   Reply With Quote
Old 05-15-2008, 08:21 PM   PM User | #4
Candygirl
Regular Coder

 
Join Date: Apr 2008
Location: Switzerland
Posts: 175
Thanks: 2
Thanked 52 Times in 52 Posts
Candygirl is on a distinguished road
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, ...).
__________________
As you've seen, English is not my mother language. Please help me to improve it :)
Candygirl is offline   Reply With Quote
Old 05-15-2008, 09:30 PM   PM User | #5
harbingerOTV
Senior Coder

 
Join Date: Jan 2005
Location: Memphis, TN
Posts: 1,765
Thanks: 8
Thanked 123 Times in 121 Posts
harbingerOTV will become famous soon enough
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.
__________________
Stop making things so hard on yourself.
i is tugbucket :: help raise tugburg :: Whitehaven Kiwanis
harbingerOTV is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:54 PM.


Advertisement
Log in to turn off these ads.