HTML to CSS: Remove the gap around a page

You should never use the marginwidth, maginheight, topmargin, leftmargin, bottommargin or topmargin attributes on <body>. These were extensions dreamt up by MS and Netscape, and have never been part of any HTML standard.

To remove the gap, use this code:

html, body {
  margin: 0;
  padding: 0;
}

Margin removes the gap in most browsers, but Opera follows the CSS2's sample style sheet for HTML 4, and uses padding. Specifying it for both the <html> and <body> elements just makes sure it's all killed off, even though I don't believe any current browser applies it to <html>.

HTML to CSS home