Click to See Complete Forum and Search --> : xhtml and body margins


JanKok
01-03-2004, 10:35 AM
I know that this question is very common in html but now I am into xhtml and want to keep the page validated the question is coming back.

I can't figure out how to set margins for the body. Is there a way to do that in css? I tried already many things but without success.

e.g. the following setings have no effect

BODY, html {
margin : 0px;
margin-top: 0px;
margin-left: 0px;
margin-right: 0px;
padding-top: 0px;
padding-left: 0px;
{

I tried to do it direct into the body tag also without success.

<body style="margin: 0px;">

any ideas?

fredmv
01-03-2004, 10:41 AM
The first one would work correctly if you closed the curleybrace with the correct one. However, all you should need is this:<style type="text/css">
/*<![CDATA[*/
body {
margin: 0;
padding: 0;
border: 0;
}
/*]]>*/
</style>That should eliminate any default whitespace in all browsers that support CSS1.

Vladdy
01-03-2004, 10:42 AM
http://forums.webdeveloper.com/showthread.php?s=&threadid=21691

JanKok
01-03-2004, 11:37 AM
Sorry for the typo:-) But in xhtml I needed to do more then only the margins

This;
body {
margin: 0px;
padding: 4px;
width: 475px;
}

finally worked out and did the job.

The idea to put width: ... in the body came from your thread you sugested vlady.

To be honest, I never before came on that idea. Thanks.

I wonder and I hope my style sheets will passes the w3c validations as well but that is the problem for tomorrow:-) in any case I have my xhtml passes the validation now.