Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Body tag and margins

Status
Not open for further replies.

mickywall

Programmer
Sep 2, 2002
88
0
0
GB
My page code has the body tag attributes

<body topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">

When I validate this code it states that there margin properties aren't acceptable. I could use the code below in a stylesheet though I was concerned about the amount of cross browser support it has?

body { margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; }

If anyone can give me some advice I'd appreciate it.

 
Opera will understand this rule but not give you the result you are looking for, because opera creates the gutter in body with padding rather than margin. That's why you should do it like this:
Code:
body {
  margin: 0;
  padding: 0;
}
 
Hi,

I am trying to figure out what causes IE 6 and Mozilla 1.7.5 to interpret the following differently. I would like to center my page using css. To start from the beginning I am creating a div with nothing in it, centering it and adding a border. I would expect both browser to "behave" similair. I think that Mozilla is showing me exactly what I want it to show me, a horizontal line. But IE 6 is giving me a box, something I didn't expect.

I would appreciate some explanation and some way to have the browser behave the same.

This is what I have in my html:
<body><div id="wrap"></div></body>

This is my CSS:
/* CSS Document */

* {
margin:0;
padding:0;
border:0;
}

body {
text-align:center;
}

div#wrap {
width: 750px;
margin:0 auto;
border:1px solid black;
}

Hope to hear from you
Greetings
Zackat
 
Complete your html with a valid doctype. Other than that, IE might want to make room for text in the box, so you might want to specify font-size: 0; for IE. But since you're probably not looking to output a line (there are easier ways to do that), you might simply ignore that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top