Kona wrote:
I've created a style for a div that is set to a specific height. My
question is that if the content in this div is larger will it resize to
fit the new content?
The CSS 2 recommendation doesn't say:
"10.6.3 Block-level, non-replaced elements in normal flow, and floating,
non-replaced elements
If 'top', 'bottom', 'margin-top', or 'margin-bottom' are 'auto', their
computed value is 0. If 'height' is 'auto', the height depends on whether
the element has any block-level children. If it only has inline-level
children, the height is from the top of the topmost line box to the bottom
of the bottommost line box. If it has block-level children, it is the
distance from the top border-edge of the topmost block-level child box, to
the bottom border-edge of the bottommost block-level child box. Only
children in the normal flow are taken into account (i.e., floating boxes
and absolutely positioned boxes are ignored, and relatively positioned
boxes are considered without their offset). Note that the child box may be
an anonymous box."
-- <URL:http://www.w3.org/TR/REC-CSS2/visudet.html#q1 7>
I think that the implication is that if the height property is set, the
height of the element is whatever you have set it to (hey, it makes sense
:) ). So then we need to look at the overflow property definition:
<URL:http://www.w3.org/TR/REC-CSS2/visufx.html#pro pdef-overflow>
The initial value of the overflow property is 'visible', which means that if
the content of the element is overflowing, it should "spill out" of the
element.
Of course, this doesn't address the option of user-agent stylesheets, but
none of the values available for the overflow property allow for expanding
an element's height in this way.
In practice, I have observed Internet Explorer, Mozilla, and Opera to expand
the height of an element to accommodate its contents. Konqueror, on the
other hand, overflows properly.
It would seem to me that you are actually looking for the 'min-height'
property, and it would be unwise to depend on this out-of-spec behaviour to
continue to work. Internet Explorer doesn't support this property though.
One workaround is to specify the height and min-height to the same length,
and then override the height property back to 'auto' with one of the many
techniques that hides a CSS rule from Internet Explorer. The drawback to
this workaround is that Konqueror doesn't understand the 'auto' keyword for
the height element [1], and so it will not render the way you want it to in
this browser.
[1] This has been fixed in HEAD, but I don't think this bugfix will make it
out to a public release until KDE 3.2.
--
Jim Dabell