views:

374

answers:

3

Why is there so much extra space in FireFox between the two floated blocks?

<html>
<head>
 <style type="text/css">
  #Container-900px { 
    width:900px;
   padding: 10px;
   border: 1px solid #CCCCCC;
   }
    #Container-900px .left { float:left; width:435px; height:300px; }
   #Container-900px .right { float:right; width:435px; height:300px; }

  /* float clearing for IE6 */
  * html .clearfix{
    height: 1%;
    overflow: visible;
  }

  /* float clearing for IE7 */
  *+html .clearfix{
    min-height: 1%;
  }

  /* float clearing for everyone else */
  .clearfix:after{
    clear: both;
    content: ".";
    display: block;
    height: 0;
    visibility: hidden;
    font-size: 0;
  }

   /* CSS3 Styles */
  #Container-900px { 
   -moz-box-shadow: 0px 0px 12px #CCC; /* Firefox */
      -webkit-box-shadow: 0px 10px 12px #CCC; /* Safari, Chrome */
      box-shadow: 0px 0px 12px #CCC; /* CSS3 */ 
    }
   #Container-900px .left {
     background-color: rgb(238, 238, 238);
   }
   #Container-900px .right {
        background-color: rgb(238, 238, 238);
      }
 </style>
</head>
<body>
<h1>Software</h1>
 <div id="Container-900px">
  <div class="left">

  </div>
  <div class="right">

  </div>
 <div class="clearfix">&nbsp;</div>
 </div>
</body>
</html>
+6  A: 

Because the doctype is omitted which causes IE to render in quirksmode (which is bad). If you have validated it with the W3 HTML validator, it should also have errored about a missing doctype.

Adding a strict doctype should make the HTML and CSS to behave consistent among all major browsers (leaving aside the fact that MSIE has still many bugs left to potentially fix).

<!doctype html>
<html lang="en">
    <!-- here you go -->
</html>

Further also give #Container-900px .left and #Container-900px .right a width of 445px so that it fits nicely along the 10px margin of the container.

#Container-900px .left { float:left; width:445px; height:300px; }
#Container-900px .right { float:right; width:445px; height:300px; }

This way it looks good and the same in all browsers.

BalusC
A: 

Compared to what? The size of the floated elements is 435px with 30px between them for the expected total of 900px. It looks the same in FF, Opera and Chrome. I don't have IE to look at. Perhaps you're missing a doctype?

Rob
A: 

Use css reset: http://meyerweb.com/eric/tools/css/reset/ might help. it "normalizes" default rendering between browsers.

mhughes