whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.02k stars 2.62k forks source link

Slowly removing/reducing the margin collapsing quirk. #10296

Open bfgeek opened 4 months ago

bfgeek commented 4 months ago

What is the issue with the HTML Standard?

Hi all,

Occasionally we (Blink) get bug reports about the margin collapsing quirk. Either a developer doesn't get a margin when they are expecting one, and/or there is a subtle difference between implementations.

See: https://html.spec.whatwg.org/#margin-collapsing-quirks

We (Blink) suspect it's possible to slowly remove/reduce this quirk by slowing limiting the cases it applies.

We are prepared to (slowly) start removing it by removing the quirk for various elements, for example starting with pre, xmp, plaintext, listing.

It's plausible (but not a certainty, just an example) that we'll end up in a situation where the quirk will apply to say p, h1, h2 and only in the <body>. Unfortunately due to how margin collapsing works, this is difficult (for us) to use-count, hence starting small with some of the lesser used elements.

  1. Is there appetite for this? I've previously had some initial tentative discussions with @emilio and @dholbert .
  2. If so - practically speaking we are willing to slowly turn off this behaviour (behind a killswitch), then after the release is stable for 1-2 months update the HTML spec with the part which we've limited/removed. We'd obviously like a upfront agreement for this.

Thoughts?

Thanks, Ian

annevk commented 4 months ago

Why not recommend them to use <!doctype html>? It's not entirely clear to me what the upside is of creating subtle breakage for the long tail of websites.

karlcow commented 4 months ago

@bfgeek do you have example of websites where this is happening? That would be great.

bfgeek commented 2 months ago

So there are a few reasons why I believe this is good generally for the web platform:

@karlcow - We don't have a use-counter in place for this - its actually relatively difficult to determine when this would trigger.

bfgeek commented 5 days ago

Sep 2024 update - we've received some more bug reports with developers getting confused by the margin collapsing quirks.

Psychpsyo commented 5 days ago

Sep 2024 update - we've received some more bug reports with developers getting confused by the margin collapsing quirks.

If this is referring to https://issues.chromium.org/u/1/issues/365516487 (my issue): The main problem isn't the quirk, the main problem is that your dev tools pretend the quirk doesn't exist and end up showing values that don't line up with the visual behavior on the page.

Also, on the note of usage counting and pages where this is happening: The header on this page is rendered in quirks mode in a way that would break if the quirk were to be removed entirely. It is also already broken in Firefox, but I think that's due to differences in the user agent style sheets(?)

Psychpsyo commented 5 days ago

I looked into this a bit more and, if I'm not mistaken, the Blink implementation of this part of the spec is currently wrong. I've made a web platform test for this and I suspect that this is the source of at least part of the confusion that developers are facing.