Improve Site Performance Increase Site Traffic Monitor Site Uptime Webmaster Resources NetMechanic Home Looking For Help? Partner Programs Privacy Policy Contact Us Press Room
NetMechanic Home LOGIN | HELP | ABOUT US | PRODUCTS | SITE MAP
NetMechanic Menu
Over 52 Million Web Pages Tested!     
 
cascading style sheet tips.
search.
Search for:


Your Email:

I would like to receive my newsletter in:
HTML format
Text format


css tip.
Volume 8 (2005)
   September
   June
   April
   March
   January

Volume 7 (2004)
   November
   September
   July
   June
   May
   April
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 6 (2003)
   December
   November (Part 2)
   November
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 5 (2002)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 4 (2001)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June (Part 2)
   June
   May (Part 2)
   May
   April (Part 2)
   April
   March (Part 2)
   March
   February (Part 2)
   February
   January (Part 2)
   January

Volume 3 (2000)
   December (Part 2)
   December
   November (Part 2)
   November
   October (Part 2)
   October
   September (Part 2)
   September
   August (Part 2)
   August
   July (Part 2)
   July
   June
   May
   April
   March
   February
   January

Volume 2 (1999)
   December
   November
   October
   September
   July
   June
   May
   April
   March
   February
   January

Volume 1 (1998)
   December
   November
   October
   September

 

CSS Tip:
Non-Tiling Background Images

by Larisa Thomason,
Senior Web Analyst,
Keynote NetMechanic

  
December 2002
Vol. 5, No. 23
 • Promotion Tip
 • Load Time Tip
 • CSS Tip
  

When a plain white or other solid background color doesn't create the effect you want, you can always use a background image on your page. But a background image included using basic HTML may look unattractive when it tiles (repeats itself on the page). You can use style sheets to control the placement and display of background images.

Use The "no-repeat" Option

You can add a background image to the BODY tag of your document using basic HTML like this:

<body background="bgImage.jpg">

But like most HTML formatting techniques, you don't have much control over how that image displays for your visitors. Check out this sample page for an example. The background image tiles (or repeats) on the page and fills the available space in the browser window.

Cascading Style Sheets (CSS) give you the ability to stop the tiling effect by using the "no-repeat" value:

<style type="text/css">
body
{
background:url(bgImage.jpg) no-repeat;
}
</style>

Now check this sample page and resize it. See the difference?

Other Style Options

The simple example above may be all you need, but probably not. The background image will display in the top left corner of the browser window and that's not always the ideal location. You can use the "center" option to center the image on the page:

<style type="text/css" >
body
{
background:url(bgImage.jpg) no-repeat center;
}
</style>

Note that this centers the image on the whole page (except in Netscape 4.7, which doesn't support the "center" value). If your page is quite long then visitors may not see the background image until they scroll down the page.

It's a good idea to also use a complementary background color even if you expect the background image to fill the browser window. Remember that images take longer to load than color (which is rendered by the browser). A complementary background color avoids an ugly flash of a contrasting color before the image displays. Our story on Background colors and images contains some good examples.

Just include the complementary color value inside the background style definition.

<style type="text/css" >
body
{
background: #31CEFF url(bgImage.jpg) no-repeat center;
}
</style>

And beware of using large, fat images as your background. After you add the background image, check your page download time using the Load Time Check feature of HTML Toolbox. It will alert you to slow-loading pages that may drive visitors away from your site.

Be Careful With Background Images

A nice background image can make a page stand out from the crowd. But be careful not to let it interfere with the actual content on your page. Be sure there's good contrast between text on your page and the background image or color.

That's important for overall page accessibility and usability. If visitors can't easily read your page content, they'll quickly jump to a more useful site.

And one last thing: don't get so excited by graphics that you forget what's really important about your page - the content. Never include important information inside images unless you've also put it in text format as well.

Search engine spiders use text content to index and rank your page. Visitors with disabilities listen to page content with screen readers. Images can make your page look attractive to visitors, but good content is what will get them to your page and keep them there!



Rate This Tip:
Not Useful Useful Very Useful   
 
NetMechanic Tools
HTML Toolbox
Browser Photo
Server Check
Search Engine Starter
Search Engine Tools
GIFBot
Newsletter
HTML Tutorial and Tips
Search Engine Tutorial
Accessibility Information
Browser Problem Tutorial

Company Info
Products
About Us
Contact
Advertise
Link To Us
Jobs
Privacy Policy
Partner Programs
Press Room
RSS Feed
Support
 



Powered by Overture!

 
     
 
   
 
     


Keynote Home
Copyright © 1996-2007,
Keynote NetMechanic
All rights reserved.