Re: Cascading style sheet question

Subject: Re: Cascading style sheet question
From: Deborah Ray <debray -at- RAYCOMM -dot- COM>
Date: Fri, 17 Jul 1998 07:27:51 -0600

At 07:52 PM 7/16/98 -0700, Richard asked:
>Can someone please explain to me how to use cascading style sheets to
>set the background color of a page?

Your best bet would probably be to embed
the style sheet in the <HEAD> of the HTML
document. (You have other options for
connecting the style sheet to the HMTL
document, but embedding is a good choice
for simpler applications.)

For example, if you want to have a blue
background, your code might look
like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Final//EN">
<HTML>
<HEAD>
<TITLE>Hairy Spiders</TITLE>
<STYLE TYPE="text/css">
<!--
BODY {background: #0000FF}
-->
</STYLE>
</HEAD>
<BODY BGCOLOR="#0000FF">
...

Note that
* You should use the Comment tag to hide the style
sheet from older browsers that don't support them.
* You should use the BGCOLOR= attribute in the
<BODY> tag to accommodate older browsers.
* You can use either the RRGGBB number or the
color name (such as BLUE, RED, etc.) in the style
sheet.

You could also insert an image instead of a color,
like this:

BODY {background: url(filename.gif) repeat-y}

This code will tile an image vertically down
the page. (Use repeat-x for horizontal tiling,
or neither repeat-x nor repeat-y for regular
tiling.)

Or, you could specify both an image and a background
color that shows up where the image doesn't,
like this:

BODY {background: #0000FF url(filename.gif) repeat-y}

Finally, be aware that style sheet support is
*very* flaky, so be sure to test all style sheets
thoroughly. For example, the "official" code for
applying these sample backgrounds is
"background-color" and "background-image," but I'll
be darned if I could get that code to work consistently.
The shortened version shown here works fine....

Hope this helps!
Deborah


**************************************************************
* Deborah S. Ray, debray -at- raycomm -dot- com, http://www.raycomm.com/
* co-author _Mastering HTML 4.0_, _HTML 4 for Dummies Quick
Reference_, _The AltaVista Search Revolution_, and others.
* RayComm, Inc., currently accepting contract inquiries.




Previous by Author: TECHWR-L site update
Next by Author: Q: Convert Interleaf to PageMaker?
Previous by Thread: Re: Cascading style sheet question
Next by Thread: Testimonials


What this post helpful? Share it with friends and colleagues:


Sponsored Ads