Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder
    Join Date
    Mar 2007
    Posts
    357
    Thanks
    46
    Thanked 22 Times in 21 Posts

    Background vs Img?

    Is there any benefit to using css background: url(); over <img> elements and vice versa?

  • #2
    Senior Coder jcdevelopment's Avatar
    Join Date
    Oct 2007
    Location
    Cowboy Nation
    Posts
    2,182
    Thanks
    174
    Thanked 257 Times in 257 Posts
    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.

  • Users who have thanked jcdevelopment for this post:

    flynch01 (05-15-2008)

  • #3
    Senior Coder
    Join Date
    Aug 2002
    Location
    UK
    Posts
    2,789
    Thanks
    2
    Thanked 14 Times in 14 Posts
    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.

  • #4
    Regular Coder Candygirl's Avatar
    Join Date
    Apr 2008
    Location
    Switzerland
    Posts
    184
    Thanks
    3
    Thanked 56 Times in 56 Posts
    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, ...).
    "Imagination was given to man to compensate for what he is not;
    a sense of humour to console him for what he is."
    -Francis Bacon

  • #5
    Senior Coder
    Join Date
    Jan 2005
    Location
    Memphis, TN
    Posts
    1,801
    Thanks
    8
    Thanked 131 Times in 129 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •