Click to See Complete Forum and Search --> : Strategy for managing various body tags within the same website


NatuScape
08-17-2007, 03:21 PM
Hello!

I'm getting my act together and finally using CSS for all formatting on my website, including the body tag. There are a few pages, though, for which I'd like to NOT have the background image display and have different margins, but everything else from the default.css file (text, tables, etc.) to continue to apply.

What's the best strategy to format these differentiated pages without having to create a whole new .css file with some repeated tags, but a different body? Or is that the way to do it? I tried editing the body tag directly on one of those pages, but I don't know how to tell it not to apply the background and have standard margins.

Thanks in advance!!

Me :)

dtm32236
08-17-2007, 03:52 PM
If it's just a couple attributes you're changing (ie. margin, background-image, etc...):

If you do <body style="margin:0px; background-image:none">
this overwrites the default attached CSS.

does that make sense?
any css you put in a tag, will overwrite the existing css from your stylesheet.

I hope that answers your question.

NatuScape
08-17-2007, 04:21 PM
Yes, thank you! The "background-image:none" worked like a charm!!

I'd like the margin to be the default value so these pages have a bit of margin around them (the rest of the website is set at 0px for top and left), how do I tell it that I want default margins? Or what's the value so I set it to that? I tried "auto", but that didn't do the trick...

Thanks again!

Me :)

TJ111
08-17-2007, 04:40 PM
If your making the same changes on multiple changes, your best option is to make a class for the items you want to have different version of. For example if you could have:


body {
margin:0px;
padding:0px;
width:100%;
background-image:url(bgImg.jpg);
}
body.alternate {
margin:15px;
background:none;
}

Then on the pages you want the different body just change the <body> tag to <body class="alternate">

dtm32236
08-17-2007, 04:45 PM
i dont know if this will work, but try

margin:1em 1em 1em 1em;

NatuScape
08-17-2007, 08:19 PM
Thank you both!! The 1em worked out and I used the class for the body tags of the pages I wanted to have no background image.

I know there's lots of reasons why I love this website :) :)

Enjoy your weekend!

Me :)

dtm32236
08-19-2007, 06:53 PM
glad we were able to help.

take care.