PDA

View Full Version : backgrounds for multiple html docs?


bradyj
04-21-2003, 08:37 PM
I would like to make one css for all of my 22 pages... however, each html doc uses a different background file depending on the page.

How would I create a CLASS in each html doc to specify which CLASS to read in the css?

To elaborate; would I put it in the body somewhere for each html page:
<body CLASS="login">
... that would be a new class for each document?

Then I could go to my css and create:
body.login { }
...with all my css settings for the background in the bracket.

Let me know if I'm doing this backwards and you have some other methods for me:confused:

arnyinc
04-21-2003, 09:07 PM
Does every page have a different background? You won't be gaining much by using CSS then.

What you said is correct. Just give the body a class name.

<html>
<head>
<style type="text/css">
body.page1 {background-image:url("pic1.gif") }
body.page2 {background-image:url("pic2.gif") }
</style>
</head>

<body class="page1">
<center>

The background of this page is utilizing an image
that is repeated (by default) to fill the browser window.

</center>
</body>
</html>

Catman
04-21-2003, 09:14 PM
Not to mention the fact that a different background on each page won't do much for site continuity.

Roy Sinclair
04-21-2003, 09:17 PM
Use a common CSS file with common styles for all the styles which are used on multiple pages but for styles which are used on only one page and aren't likely to be used on another page in the future go ahead and code those styles into the page which uses them. That way you don't end up with styles in your CSS file which aren't used except on just one page, there's no need to bloat the CSS file with those styles.

bradyj
04-21-2003, 11:26 PM
I know that little benefit will come from me using this technique via external style sheet on the fly, but it will eliminate the need for me to open 22 documents. Thank you for reassuring me about the code arnyinc, I'll work on it right now.:thumbsup:

as for the comment Catman, this isn't your run of the mill site that requires continuity -- we're going for marketing, not a basic site with a basic look. I know, contradictory to what the web was made for -- but I don't need to follow every rule.

Roy Sinclair , I'll keep that in mind -- from what I've read, I usually keep my design settings from the structure settings... so I don't pollute the html. It's not always a necessity I guess.

brothercake
04-21-2003, 11:51 PM
You're right to do it with CSS and not body attributes, for exactly the reason you said - don't pollute the HTML with design code.

bradyj
04-21-2003, 11:57 PM
thanks brothercake:)

ronaldb66
04-22-2003, 11:57 AM
I usually keep my design settings from the structure settings... so I don't pollute the html. It's not always a necessity I guess.
If you want to keep all your CSS in external files, you could divide it up as Roy Sinclair suggested but rather then using internal styles, include the deviant styles in an external file of their own and specify two external style sheets in each document. That way, you can alter page-specific style settings without ever touching the document itself.

Roy Sinclair
04-22-2003, 03:06 PM
Ronald has it right, what he suggests allows you to avoid both the polluting of the html and the bloating of the css.

bradyj
04-22-2003, 04:32 PM
That sounds like a good compromise -- and it fixes the problem on both sides of polluting the HTML and bloating the CSS... I'll do just that. Thank you all!:thumbsup: