Variable width DIVs

by Nate Harel <nharel(at)>

 Date:  Mon, 23 Feb 2004 12:23:59 -0500
 To:  hwg-techniques(at)
  todo: View Thread, Original
Hi all,

I am trying to be a good forward looking doobie using CSS for layout rather 
than tables, but have come up against a stumper.

This problem is relatively simple with tables, but I cannot figure out how 
to make a DIV layer have a variable width inside another layer.

I have set up this sample to explain. The main layer is the shaded one that 
is set up to be centered on the page and to fill 97% of the page. This 
gives me a small white border around the edges and keeps the width variable 
relative to the screen viewing size.

I then created another layer within this one, to hold my content. 
Naturally, I want this content to fall within the shaded area (with a small 
margin), so I set up this layer to have a variable width as well. 
However,  the end effect is that this width is also showing as relative to 
the screen. In other words, when the screen shrinks and the shaded area 
gets small, the text falls over the right edge.

With a table this would be easy. How do I make it size relative to the 
parent layer?


                             Nate Harel
                         NetTech Services
                           56 Pickering Street
                   Needham, MA  02492-3198
                       Tel:  1-781-559-8176 x89
                   Toll Free: 1-866-302-6222 x89
                      FAX:  1-866-302-6222
                 Email:  nharel(at)


HWG hwg-techniques mailing list archives, maintained by Webmasters @ IWA