So I’m really trying to use divs exclusively, as opposed to using tables for layout purposes, but I’m still getting stuck here and there. Today I have one of those cases.
Consider the following markup:
<div style="width:943px;margin:0px auto;height:auto">
<div style="display:block;clear:both">
<div style="float:left;display:block-inline;clear:none;background:url(tl.png);width:26px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(t.png) repeat-x;width:865px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(tr.png);width:26px;height:25px"></div>
</div>
<div style="height:auto;display:block;clear:both">
<div style="float:left;width:26px;display:block-inline;clear:none;background:url(l.png) repeat-y;width:26px;height:100%"></div>
<div style="padding:0 15px;height:100%;float:left;width:835px;display:block-inline;background:#FFF;clear:none;">
<br />
Some text heeere.
<br />
Some more text heeere.
</div>
<div style="float:left;width:26px;display:block-inline;clear:none;background:url(r.png) repeat-y;width:26px;height:100%"></div>
</div>
<div style="display:block;clear:both">
<div style="float:left;display:block-inline;clear:none;background:url(bl.png);width:26px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(b.png) repeat-x;width:865px;height:25px"></div>
<div style="float:left;display:block-inline;clear:none;background:url(br.png);width:26px;height:25px"></div>
</div>
</div>
Now this is what’s its doing:
Note that it’s going slightly past the page height.
This is what I want it to do:
I want it to fluidly “fit” to the text without me specifying a height. It seems that the problem lies with the two side divs that won’t work unless you specify the height as 100%. Is there maybe another/easier way to do this?
Thanks!


You asked for it, so here goes. This is my hand crafted, cross-browser, standards-compliant method of doing image borders on flexible containers.
I’ve assumed an image border size of 16px here, you will need to adjust this to suit. Also, for clarity in the absense of images I have added borders. Thse should be removed, obviously.
Demo.