1. Computing & Technology

Discuss in my forum

Use CSS to Zero Out Your Margins and Borders for Consistent Results in Browsers

CSS Margins, Padding, and Borders Make a Consistent Page

By , About.com Guide

Most Web browsers have different default settings for the base margins and padding. This means that if you don't set a margin and padding on your body and html tags, you could get inconsistent results on the page depending upon which browser you're using to view the page.

The best way to solve this is to set all the margins and paddings on the html and body tags to 0:
html, body {
  margin: 0px;
  padding: 0px;
}

This will start your design in the same place on all browsers.

Borders

You may be thinking "but no browsers have a border around the body element by default". This is not strictly true. Internet Explorer has a transparent or invisible border around elements. Unless you set the border to 0, that border will mess up your page layouts. So add the following to your body and html styles:
html, body {
  margin: 0px;
  padding: 0px;
  border: 0px;
}

©2012 About.com. All rights reserved.

A part of The New York Times Company.