html – margin-bottom question,is this IE’s BUG? – Education Career Blog


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "">
    border:1px solid green;
    border:1px solid blue;
    border:1px solid red;
<div id="boxTop">test</div>
<div id="box1">test</div>
<div id="box2">bottom</div>

check it here

in IE,why has a padding in #box1 and #box2 ? how to fix it?

alt text


What you’ve come across is the IE hasLayout “feature”.

Getting #box2 to have layout will fix this issue. If you are concerned with IE7, add min-height: 0; to the style for #box2, like so:



There also seems to be a big with the first element on the page having a margin. I tried to remove the margin-bottom and add a margin-top to the box1 and it works. Have a look here:


Different browsers have different default margins and paddings. Reset this at the top of your CSS and you should not have these differences.

The simplest but not very efficient reset is:

* { margin:0; padding:0 } /* '*' affects everything (all elements) */

One I’ve been using recently is:

html,body,h1,h2,h3,h4,h5,p,ul,li,form,button,div { margin:0; padding:0 }

Google ‘CSS Reset’ and you should see many variations, some claiming to be better than others. My take is use the minimum that works for you.

One other approach is to not use one at all, and just set the properties you need as you polish your design. Read this for a deatailed explanation:



property seems to be problem in IE. Even though we set margin and padding to 0, still rendering is not as expected in IE. Try to use span instead of possible in place of 2nd div and remove float:left property.

Leave a Comment