treehouse : what would you like to learn today?
Web Design Web Development iOS Development

When to use empty divs + background-image property

  • Hi all,
    Basic question: When should you use background images as opposed to placing images in your html. I've noticed that some folks use empty divs with and set images using the background-image property as much as possible. I am wondering when is that advantageous and when should you just go ahead and stick the image tag in your html? Hope this isn't to general a question.

    Brandon
  • Sometimes it is sometimes it isnt :)

    In the design of your site, you should use the BG image to bring in images that arnt that important. I use the old <img> tag on things that I want for example google to pick up on. On the front page of my site i have some UL's set up to display some of the services I offer, the image in the first LI I could have pulled in as a BG image, but instead I used a <img> tag. The reason I did this is its now an actual important element in the site, with all the decriptive text info it needs to be searched.

    In my opinion - <img> things that arnt site stucture, but are things like images in posts or your gallery, this way you give google something else to chew on :)