The default bug view has changed. See this FAQ.

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

RESOLVED FIXED in mozilla10

Status

()

Core
Layout: Tables
P3
normal
RESOLVED FIXED
16 years ago
9 months ago

People

(Reporter: Hixie (not reading bugmail), Assigned: Ehsan)

Tracking

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

Trunk
mozilla10
css2, dev-doc-complete, testcase
Points:
---
Dependency tree / graph
Bug Flags:
wanted1.9.2 -
in-testsuite +

Firefox Tracking Flags

(Not tracked)

Details

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

Attachments

(1 attachment, 1 obsolete attachment)

922 bytes, text/html
Details
(Reporter)

Description

16 years ago
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.
(Reporter)

Comment 1

16 years ago
(The block case is at http://www.hixie.ch/tests/adhoc/css/box/block/007.xml)
Keywords: css2, mozilla1.0, testcase
Whiteboard: [Hixie-P3]
Status: NEW → ASSIGNED
Priority: -- → P2
Target Milestone: --- → mozilla1.0

Comment 2

16 years ago
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
(Reporter)

Comment 3

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

Updated

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

Comment 4

16 years ago
*** Bug 109517 has been marked as a duplicate of this bug. ***
Priority: P2 → P3

Comment 5

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

Comment 6

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

Comment 7

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

Comment 8

12 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

12 years ago
Created attachment 200827 [details]
simple HTML testcase

Simplified HTML test without display:table to see what IE does.

Comment 10

12 years ago
Created attachment 200829 [details]
simple HTML testcase (the right one)

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

Comment 12

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

Comment 13

11 years ago
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!

Comment 14

10 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

10 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
Status: ASSIGNED → NEW
QA Contact: amar → layout.tables

Comment 16

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

gary

Comment 17

10 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

10 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.

gary

Comment 19

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

Comment 20

10 years ago
Dependent on bug 50959
Depends on: 50959

Comment 21

8 years ago
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
Flags: wanted1.9.2?
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?

Comment 23

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

Updated

6 years ago
Keywords: dev-doc-needed
(Assignee)

Comment 26

6 years ago
This was fixed by bug 659828.  I enabled the tests for this bug: https://hg.mozilla.org/mozilla-central/rev/2d5d6e1c4418
Status: NEW → RESOLVED
Last Resolved: 6 years ago
Flags: in-testsuite? → in-testsuite+
Resolution: --- → FIXED
Target Milestone: Future → mozilla10

Updated

6 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.
Keywords: dev-doc-needed → dev-doc-complete

Comment 28

9 months 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:
> 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.