W3C home > Mailing lists > Public > public-css-archive@w3.org > February 2018

[csswg-drafts] [CSS2] Used value of margin properties

From: Morten Stenshorne via GitHub <sysbot+gh@w3.org>
Date: Fri, 16 Feb 2018 15:10:50 +0000
To: public-css-archive@w3.org
Message-ID: <issues.opened-297816265-1518793849-sysbot+gh@w3.org>
mstensho has just created a new issue for https://github.com/w3c/csswg-drafts:

== [CSS2] Used value of margin properties ==
I'm looking into how Window.getComputedStyle() behaves for margins.


So the resolved value for margins is typically the used value. For percentage resolution and auto margin resolution, this seems to be what browsers do. However, nobody behaves according to spec in over-constrained situations:


The spec says that the used value of either margin-left or margin-right should be changed to satisfy the constraint (margin + border + padding + width == containing block width).

Instead, all browsers just use the computed value of the margin property that should be overridden.

<div style="width: 400px;">
  <div id="elm" style="margin-left:0; margin-right:10px; width:100px;"></div>

The used value of #elm's margin-right should be 300px, but getComputedStyle(elm).marginRight returns 10px in both Chrome, Edge and Firefox.

Should this be considered browser bugs, or should the spec be fixed, or am I holding the specs wrong?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2328 using your GitHub account
Received on Friday, 16 February 2018 15:10:54 UTC

This archive was generated by hypermail 2.4.0 : Tuesday, 5 July 2022 06:41:24 UTC