Jump to content

saila.com

Online media matters

Can I get rid of the white space “gutter” around my HTML pages?

There’s an easy way to do this using style sheets, as well as a way to do this separately for Netscape and Internet Explorer.

The style sheet solution can cause some problems in Netscape 4.x, but is the best bet for long-term viability:
<body style="margin: 0; padding: 0;">

Netscape 4.x Fix:
<body marginwidth="0" marginheight="0">

Internet Explorer 4+ Fix:
<body topmargin="0" leftmargin="0">

Safe Fix:
Combine the two individual browser solutions together with the style sheet solution (this won’t validate, but does work):
<body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">

This <body marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" style="margin: 0; padding: 0;">

“Valid” Fix:
To produce a page that validates, place this style block in the document’s head:
<style type="text/css" media="screen"><!--
  body { margin: -10px 0 0 -10px; }
  html body { margin: 0; padding: 0; }
//--></style>

The first line solves the margin-spacing problem in Netscape 4.x, the second uses the descendent selector to set the margins to the correct value of 0 in the other fourth-generation and higher browsers

To remove the inset appearance of the canvas on Internet Explorer (Windows) append border: none; to the body’s style rule.