Submit Your Article Forum Rules

Results 1 to 10 of 10

Thread: Background image: How to?

  1. #1
    WebProWorld MVP kgun's Avatar
    Join Date
    May 2005
    Location
    Norway
    Posts
    7,999

    Question Background image: How to?

    I use CSS and images for my styling, but don't use the

    background-image:url('backgroundimage.gif');

    CSS styling rule.

    Take the last link in my example. Looking at the code you will find markup like this

    <img alt="" src="http://www.oopschool.com/styling/gblnav_left.gif" height="32" width="4" id="gnl">

    My simple question:

    Is there any reason that I should change to the first format and link to images in the CSS stylesheet?

  2. #2
    Senior Member ran_dizolph's Avatar
    Join Date
    Jul 2005
    Posts
    561

    Re: Background image: How to?

    Well, the format you use isn't really a 'background' image per se, it's directly in the code. Furthermore what you've displayed is deprecated (height and width inline).

    The idea with background images as to my understanding, is to use them more for layout, as opposed to actual content. That's the way I separate the two. If an image has to do with the content on the site, use the img tag, if not, use a background image.

  3. #3
    Senior Member weslinda's Avatar
    Join Date
    Mar 2006
    Posts
    975

    Re: Background image: How to?

    Guess it depends on if the image is unique for various pages vs the style sheet. If the image is the same sitewide, it makes it easier to change that image if you're working in css, as you can use a new image, change the placement of the image, remove the image, so forth and so on.

    My 2 Cents on that one.
    We offer a total eCommerce solution with eCommerce Web Design using Pinnacle Cart

  4. #4
    Senior Member ronchalice's Avatar
    Join Date
    Oct 2006
    Posts
    186

    Re: Background image: How to?

    Is it not also true that a CSS background image is only loaded (and painted) once if the CSS is the same from page to page but the img tag is loaded each time it occurs?

    Thanks,

  5. #5
    WebProWorld MVP Doc's Avatar
    Join Date
    Jun 2009
    Location
    Baja California, Mexico
    Posts
    927

    Re: Background image: How to?

    Quote Originally Posted by ronchalice View Post
    Is it not also true that a CSS background image is only loaded (and painted) once if the CSS is the same from page to page but the img tag is loaded each time it occurs?

    Thanks,
    Very good point, Ron!

  6. #6
    Junior Member
    Join Date
    Sep 2009
    Posts
    5

    Re: Background image: How to?

    ron you have put up an important point.why there is no comment on this.

  7. #7
    Junior Member
    Join Date
    Sep 2009
    Posts
    10

    Re: Background image: How to?

    if you are planing to link that image then use it in the html code.. but if the image is just a background image and you would like to change the image in future to something else then its better to put it in css file just to keep everything organized as well

  8. #8
    Senior Member Uncle Dog's Avatar
    Join Date
    Apr 2008
    Posts
    342

    Re: Background image: How to?

    Also, if a visitor decides to print your page, background-image(s) don't ordinarily show up and waste ink or obfuscate text. Normally I put a logo in an img tag so that it is always printed.

  9. #9
    Administrator weegillis's Avatar
    Join Date
    Oct 2003
    Posts
    5,793

    Re: Background image: How to?

    Sorry, kgun, for butting in...

    Quote Originally Posted by ran_dizolph View Post
    Furthermore what you've displayed is deprecated (height and width inline).
    Link: HTML img tag

    Note that width and height are indeed, still optional attributes of the IMG tag. Including them helps browsers reserve space in the layout and move on to other code without having to wait for the download.

  10. #10
    Junior Member
    Join Date
    Oct 2009
    Posts
    1

    Re: Background image: How to?

    No there is no such compulsion. If you are getting the desired results with this code, then do not change it, just because someone has said you to change.

Similar Threads

  1. Resizing background image (CSS)
    By Laurentvw in forum Graphics & Design Discussion Forum
    Replies: 1
    Last Post: 03-30-2007, 02:29 PM
  2. Background Image Problem
    By chingy in forum Graphics & Design Discussion Forum
    Replies: 5
    Last Post: 01-23-2006, 02:20 AM
  3. Static Background Image - Need Help!
    By Punk Rich in forum Graphics & Design Discussion Forum
    Replies: 6
    Last Post: 09-27-2005, 04:38 AM
  4. Using a background image
    By michaelstevenson in forum Graphics & Design Discussion Forum
    Replies: 2
    Last Post: 01-21-2005, 08:26 AM
  5. CSS background image
    By emi_b in forum Graphics & Design Discussion Forum
    Replies: 9
    Last Post: 05-18-2004, 11:17 AM

Posting Permissions

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