Here's the problem:
The page contains inline text, then some additional pairs of text which
are floated right and left. (This is a transcript of a historical legal
document with signatures on the right and witnesses on the left). The
'document' ends with no additional inline text. The background of the
entire document should be brown inside a white body, (in this test the
body is inside a green HTML structure) but it isn't (the actual
appearance depends greatly on what browser you are using), largely
because the height of the floated boxes is not included in the height of
the 'document' box within which they are contained, per CSS2, Section
10.6.3, which states, regarding the height of a 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,..."
Thus floating boxes do not extend the height of their containing block.
That's bad when they are part of the same logical structure and you
want them to inherit their parent's color.
I've forced background-color: inherit here, but I'd much rather be able
to use the default background-color: transparent.
Here's the workaround:
I've added:
<p style="clear: both">
</p>
below the floated blocks. This extends the height of the containing
block to include them.
And now I can leave the backgrounds transparent:
The question (you knew there was going to be one, right?).
Is this ugly hack to the HTML the best way to resolve this issue with
CSS styling?
If you'd like to see one of these documents in its native environment
(without any background colors), look at
http://beallsprings.org/WC.Deed%20GG.114-15.T.html.
Thanks,
Chris Beall
The page contains inline text, then some additional pairs of text which
are floated right and left. (This is a transcript of a historical legal
document with signatures on the right and witnesses on the left). The
'document' ends with no additional inline text. The background of the
entire document should be brown inside a white body, (in this test the
body is inside a green HTML structure) but it isn't (the actual
appearance depends greatly on what browser you are using), largely
because the height of the floated boxes is not included in the height of
the 'document' box within which they are contained, per CSS2, Section
10.6.3, which states, regarding the height of a 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,..."
Thus floating boxes do not extend the height of their containing block.
That's bad when they are part of the same logical structure and you
want them to inherit their parent's color.
I've forced background-color: inherit here, but I'd much rather be able
to use the default background-color: transparent.
Here's the workaround:
I've added:
<p style="clear: both">
</p>
below the floated blocks. This extends the height of the containing
block to include them.
And now I can leave the backgrounds transparent:
The question (you knew there was going to be one, right?).
Is this ugly hack to the HTML the best way to resolve this issue with
CSS styling?
If you'd like to see one of these documents in its native environment
(without any background colors), look at
http://beallsprings.org/WC.Deed%20GG.114-15.T.html.
Thanks,
Chris Beall
Comment