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

RESOLVED FIXED in mozilla10



18 years ago
3 years ago


(Reporter: ian, Assigned: Ehsan)


(Depends on 1 bug, Blocks 2 bugs, {css2, dev-doc-complete, testcase})

Dependency tree / graph
Bug Flags:
wanted1.9.2 -
in-testsuite +

Firefox Tracking Flags

(Not tracked)


(Whiteboard: [Hixie-P2] Forward-compatible workaround in comments 19 and 21, URL)


(1 attachment, 1 obsolete attachment)

922 bytes, text/html


18 years ago
Tables don't collapse vertical margins. It works fine if you take the test and
replace "table" with "block" in the style block.

Comment 1

18 years ago
(The block case is at
Whiteboard: [Hixie-P3]
Priority: -- → P2
Target Milestone: --- → mozilla1.0

Comment 2

18 years ago
The problem is in
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

Comment 3

18 years ago
(// XXX except if the caption is not at the top of the table)
Target Milestone: mozilla1.0 → Future


18 years ago
Whiteboard: [Hixie-P3] → [Hixie-P2]

Comment 4

18 years ago
*** Bug 109517 has been marked as a duplicate of this bug. ***

Comment 5

17 years ago
*** Bug 133688 has been marked as a duplicate of this bug. ***

Comment 6

17 years ago
Reconfirmed using FizzillaCFM/2002071208. Setting All/All.
OS: Windows 2000 → All
Hardware: PC → All

Comment 7

15 years ago
*** Bug 258241 has been marked as a duplicate of this bug. ***

Comment 8

14 years ago
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.

Comment 9

14 years ago
Posted file simple HTML testcase (obsolete) —
Simplified HTML test without display:table to see what IE does.

Comment 10

14 years ago
Sorry, this one is it...
Attachment #200827 - Attachment is obsolete: true
*** Bug 327277 has been marked as a duplicate of this bug. ***

Comment 12

13 years ago
I would like to underline comment #8.
I verified the bug for Firefox on Windows 98.

Comment 13

13 years ago
Another testcase:

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!

Comment 14

12 years ago
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?

Comment 15

12 years ago
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
QA Contact: amar → layout.tables

Comment 16

12 years ago
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?


Comment 17

12 years ago
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.

Comment 18

12 years ago
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.


Comment 19

12 years ago

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

2- j.j., Scott, Ornette: please visit bugzilla etiquette
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:

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.

Comment 20

12 years ago
Dependent on bug 50959
Depends on: 50959

Comment 21

11 years ago
Updated testcase:

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:
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 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?

Comment 23

10 years ago
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-
No longer blocks: 372303
Duplicate of this bug: 372303
Ehsan has a patch for this in bug 659828.
Assignee: nobody → ehsan
Depends on: 659828


8 years ago
Keywords: dev-doc-needed

Comment 26

8 years ago
This was fixed by bug 659828.  I enabled the tests for this bug:
Last Resolved: 8 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Target Milestone: Future → mozilla10


8 years ago
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.

Comment 28

3 years ago
> 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:

Corrected link:

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.