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

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.

https://drafts.csswg.org/cssom/#resolved-values

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:

https://www.w3.org/TR/CSS22/visudet.html#blockwidth

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.

Example:
<div style="width: 400px;">
  <div id="elm" style="margin-left:0; margin-right:10px; width:100px;"></div>
</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