[thelist] css question...

rsusoeff rsusoeff at afamily.net
Fri Nov 5 11:47:40 CST 2004

On Nov 4, 2004, at 3:10 PM, Travis wrote:

> I want to nest a div within a div like so...

> <div><div style="float:left; width:50%"></div></div>

> This works great in firefox, etc, but in ie the nested div is assigned 50%
the width of the entire page - not 50% the width of the parent div.
Interestingly, if I remove the float, it works fine. Unfortuneately I need
the float.


Assign a fluid width to your containing <div>, thus:

<html lang="en">
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<style type="text/css">
html,body {
 background-color: #fff;
 margin: 0;
 padding: 0;
 text-align: center;
#outerDiv {
 background: red;
 margin: 5% auto;
 padding: 0;
 width: 90%;
#outerDiv .half {
 background: silver;
 float: left;
 margin: 0;
 padding: 0;
 width: 50%;
<div id="outerDiv"><div class="half">this is the float</div>&nbsp;</div>

HTH, Rick.

More information about the thelist mailing list