You are here: <img> or CSS background-image? « HTML « IT news, forums, messages
<img> or CSS background-image?

Posted by JWL on 10/02/06 08:34

Hi

Suppose I have a site that requires a horizontal line of four images on
each page. This is a design thing and doesn't really have much bearing
on the site's content. The images differ from page to page.

Anyway, using a CSS layout, I left-floated the four divs and placed
<img> tags in them to display the images. But now I'm thinking: would it
be better to place background images in the divs using CSS? By using
contextual selectors I could place exactly the same HTML on each page
and have the CSS select the different images, which would make things
much cleaner. Is there any reason not to do this? I'm not sure whether
to choose one or the other.

Related to that, suppose I do have a div that exists only to display a
background image:

#header {
width: 800px;
height: 100px;
background: url('banner.gif') no-repeat;
}

Is it OK to have an empty div in the HTML:

<div id="header"></div>

Or should I put a space in:

<div id="header"> </div>

Looking at people's source, I've seen both techniques, but I don't know
if it makes the blindest bit of difference to all the browsers I'm
unable to test in.

Thanks for looking!

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация