Open Bug 299685 Opened 19 years ago Updated 2 years ago

nested floated divs without 'width' are rendered strangely

Categories

(Core :: Layout: Floats, defect)

x86
Windows XP
defect

Tracking

()

UNCONFIRMED

People

(Reporter: snaury, Unassigned)

Details

(Whiteboard: [reflow-refactor])

Attachments

(2 files, 1 obsolete file)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.8) Gecko/20050511 Firefox/1.0.4

Consider following html snippet:

<div style="float: left">Text</div>
<div style="float: right"><div style="float: right">Text</div></div>

When rendered by firefox, these two "Text" labels appear on two different lines
(i.e. it's like is the second div was cleared), however when I add width
(anything that wouldn't be too large):

<div style="float: left">Text</div>
<div style="width: 50%; float: right"><div style="float: right">Text</div></div>

It is rendered fine (two labels on the same line). By reading CSS2 from W3C, I
found that floated elements must have width specified (if it is not replaceable
element, but I couldn't understand what exactly a replaceable element is).
However, other browsers I tried (ie6 and opera8) seem to automatically calculate
appropriate width for div, not producing such a strange behavior. Actually, I'm
not even sure if it is a bug or not. I'll now upload a small .html file to show
what happens when slightly more divs come into play (also with borders to show
how exactly boxes behave). If this is expected behavior (or maybe more
'undefined' behavior), I'm really sorry for misreporting it, however, just in
case, I'm marking it as 'feature request'.

Reproducible: Always

Steps to Reproduce:
Attachment #188255 - Attachment is obsolete: true
Severity: enhancement → normal
Component: General → Layout: Floats
Product: Firefox → Core
Version: unspecified → Trunk
I played around with this bug for a while and believe I can confirm that there
is something odd happening here. In the attachment below, note how, in the first
case, "Line 4" is rendered so as to overlap the right float (which itself has
been rendered on a separate line rather than to the right of the first float). 
This behavior is reminiscent of that seen with bug 279466. (Oddly, removing the
border from the "Line 1" div restores order to the world.) It would thus appear
that, under certain circumstances, including when no width has been specified,
right-floated divs are being ignored when layout is calculated.
Whiteboard: [reflow-refactor]
QA Contact: general → layout.floats
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: