Closed Bug 87277 Opened 23 years ago Closed 13 years ago

Tables don't collapse outer vertical margins [MARGIN-C]

Categories

(Core :: Layout: Tables, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla10

People

(Reporter: ian, Assigned: ehsan.akhgari)

References

(Depends on 1 open bug, Blocks 2 open bugs, )

Details

(Keywords: css2, dev-doc-complete, testcase, Whiteboard: [Hixie-P2] Forward-compatible workaround in comments 19 and 21)

Attachments

(1 file, 1 obsolete file)

See: http://www.hixie.ch/tests/adhoc/css/box/table/006.xml
Tables don't collapse vertical margins. It works fine if you take the test and
replace "table" with "block" in the style block.
(The block case is at http://www.hixie.ch/tests/adhoc/css/box/block/007.xml)
Whiteboard: [Hixie-P3]
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.0
The problem is in 
http://lxr.mozilla.org/seamonkey/source/layout/html/base/src/nsBlockReflowContext.cpp#69
the block top child is a tableouterframe, which does not carry the margin. In
order to get this for tables right: it should be checked first whether there is
caption frame, and use its top margin otherwise use the innertableframe margin
(// XXX except if the caption is not at the top of the table)
Target Milestone: mozilla1.0 → Future
Whiteboard: [Hixie-P3] → [Hixie-P2]
*** Bug 109517 has been marked as a duplicate of this bug. ***
*** Bug 133688 has been marked as a duplicate of this bug. ***
Reconfirmed using FizzillaCFM/2002071208. Setting All/All.
OS: Windows 2000 → All
Hardware: PC → All
*** Bug 258241 has been marked as a duplicate of this bug. ***
Sorry for the spam, but isn't it time to have a look on this?
It validates CSS and breaks compliance with IE and other browsers.
Attached file simple HTML testcase (obsolete) —
Simplified HTML test without display:table to see what IE does.
Sorry, this one is it...
Attachment #200827 - Attachment is obsolete: true
*** Bug 327277 has been marked as a duplicate of this bug. ***
I would like to underline comment #8.
I verified the bug for Firefox 1.5.0.1 on Windows 98.
Another testcase:

http://www.gtalbot.org/BrowserBugsSection/MozillaBugs/CollapseVerticalMarginTables.html

Expected results: there should be a gap of exactly 100px between each table

Actual results: there is a 150px gap between each table.

Opera 9.0 and IE 7 beta 2 get the expected results.

I'm voting for this bug!
Can't there be some action on this simple issue? Clearly, wrapping a table in a div works around this problem, surely hardcoding this into Mozilla is an easy task?
agreed. Looking at the original report date and seeing it was from TWO THOUSAND AND ONE .. SIX [admirable restraint] YEARS AGO...

this needs to be resolved. 
Assignee: dbaron → nobody
Status: ASSIGNED → NEW
QA Contact: amar → layout.tables
Doesn't display table establish a new formatting context, like a float or absolute positioned element?  Thus, the vertical should _not_ collapse, query?

Is this really a bug, or an aggravatingly correct rendering?

gary
You're right about display: table establishing a new formatting context, but in CSS 2.1, neither §8.3.1 (Collapsing margins) or §9.4.1 (Block formatting contexts), mention anything about margins not collapsing, other than to say that they never do for floats.

So unless I messed something, I still think it is a bug.
You are, of course, quite right.  Thanks for reminding me to RTFM before mouthing off. :)

So floats, absolutes, and inline-blocks do not collapse even with their in flow children. While elements in block formatting contexts due to having overflow set to other than visible do not collapse with their in flow children, but do collapse externally.

It would seem that elements with display table or table-cell ought to at least not collapse with their in flow children.  That would be at least what I perceive as a correct behavior.  But, if the rules say otherwise, then the bug should be fixed, or better, IMO, modify the specs to at least throw table and table-cell in with overflow: hidden||auto.

gary
Hello

1- Gary and Mike: yes, this is a valid bug

2- j.j., Scott, Ornette: please visit bugzilla etiquette
https://bugzilla.mozilla.org/page.cgi?id=etiquette.html
We're all volunteers in a community-driven project here.
"The only person who has any obligation to fix the bugs 
you want fixed is you. Never act as if you expect someone 
to fix a bug by a particular date or release. This is merely 
obnoxious, and is likely to get the bug ignored." 
Bugzilla etiquette

3- "wrapping a table in a div works around this problem":
that would be a poor and weak workaround. Increasing the number of DOM nodes is always a bad workaround. A much better workaround is to set margin-bottom of the nth table to, say, 32px, and then the margin of the nth+1 (following, next sibling) table to 0px. That way, whether vertical adjoining margin collapsing works or not, whether this bug is eventually fixed or not, the resulting margin between consecutive tables will be 32px. No javascript trick needed, no extra markup code needed; just a pure forward-compatible, future-proof CSS workaround.
A real example:
http://www.mozilla.org/access/w3c-uaag

4- "hardcoding this into Mozilla is an easy task"
Ornette, I don't think a fix is that easy. This bug is closely related to the way Mozilla implements caption into the table's margin (see attachment 98261 [details]). In any case, Ornette, you can submit a patch.
Dependent on bug 50959
Depends on: 50959
Updated testcase:
http://www.gtalbot.org/BrowserBugsSection/MozillaBugs/CollapseVerticalMarginTables.html

Forward-compatible workaround
=============================

max (x, y) = x + y 
only and only when x == 0 or y == 0
where x is the margin-bottom of a table and 
y is the margin-top of the following (next sibling, subsequent) table

Real live example:
http://www.mozilla.org/access/w3c-uaag
Whiteboard: [Hixie-P2] → [Hixie-P2] Forward-compatible workaround in comments 19 and 21
So, in today's CSS working group meeting, the group accepted option 1 in http://lists.w3.org/Archives/Public/www-style/2008Nov/0520.html in order to resolve issue 88 on CSS 2.1 (given that there aren't yet any implementations of this).  That would make this bug invalid.

That said, I'll wait a bit before changing the state of this bug.

We should also add reftests to test the correct behavior...
Flags: in-testsuite?
That decision doesn't affect this bug. That affects whether caption margins collapse with the table, not whether the table margins collapse with other things.
Flags: wanted1.9.2? → wanted1.9.2-
Blocks: 625703
Ehsan has a patch for this in bug 659828.
Assignee: nobody → ehsan
Depends on: 659828
Keywords: dev-doc-needed
This was fixed by bug 659828.  I enabled the tests for this bug: https://hg.mozilla.org/mozilla-central/rev/2d5d6e1c4418
Status: NEW → RESOLVED
Closed: 13 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Target Milestone: Future → mozilla10
Depends on: 691591
This is just listed on Firefox 10 for developers with a link to the blog post, since it's just bringing us into line with the spec.
> Forward-compatible workaround
> =============================
> 
> max (x, y) = x + y 
> only and only when x == 0 or y == 0
> where x is the margin-bottom of a table and 
> y is the margin-top of the following (next sibling, subsequent) table
> 
> Real live example:
> http://www.mozilla.org/access/w3c-uaag

Corrected link:
http://www-archive.mozilla.org/access/w3c-uaag

line 52: table {width: 100%; margin: 0px auto 32px auto;}
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: