Html – CSS floats with unknown widths don’t wrap whitespace with doctype

csscss-floatdoctypefirefoxhtml

Two divs, floated left, of unknown width. One of them has more content than fits the page, so it moves below the first (except in IE):

http://corexii.com/floatproblem/float.html

Add display:inline-table; and the big one wraps its content (consistently across browsers):

http://corexii.com/floatproblem/table.html

But introduce a doctype (not just strict, ANY doctype) and it doesn't anymore in Firefox:

http://corexii.com/floatproblem/doctype.html

How do I get the right div to wrap its content while using a doctype at the same time, reliably across browsers?

Best Solution

How do I get the right div to wrap its content while using a doctype at the same time, reliably across browsers?

Without defining widths, you cannot. I'd recommend percentage widths in this case, but it's up to you.

The default width for a div is 100% of its container (in this case the page). The first div will end up it's actual size unless you size the page to be smaller that its inherent width. Expecting consistency accross browsers without a full and valid doctype is simply an exercise in futility.