Bug 15880 - computed style height and width reflect border box dimensions
: computed style height and width reflect border box dimensions
Status: RESOLVED INVALID
: WebKit
CSS
: 528+ (Nightly build)
: All All
: P2 Normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2007-11-07 01:44 PST by
Modified: 2011-10-19 21:08 PST (History)


Attachments
Test case (871 bytes, text/html)
2007-11-07 01:46 PST, Marcus Better
no flags Details
Result with WebKit r27433 (16.04 KB, image/png)
2007-11-07 01:51 PST, Marcus Better
no flags Details
Result with Firefox 2.0.0.9 (19.73 KB, image/png)
2007-11-07 01:52 PST, Marcus Better
no flags Details


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2007-11-07 01:44:17 PST
In border-box mode, the computed height and width attributes give the border-box dimensions. This is contrary to Firefox which returns the content-box dimensions. I leave it to you to decide which is correct.
------- Comment #1 From 2007-11-07 01:46:36 PST -------
Created an attachment (id=17103) [details]
Test case

The test case shows the width and height properties of the computed style. You can also check this with the Web Inspector.

An interesting detail is that the Web Inspector gets confused: If you inspect the square DIV in the test case and look at the "Metrics" pane, it will show the box as if its contents were 50x50, excluding borders and padding. This is incorrect because the border-box is in fact 50x50 (as it should be).
------- Comment #2 From 2007-11-07 01:51:45 PST -------
Created an attachment (id=17104) [details]
Result with WebKit r27433
------- Comment #3 From 2007-11-07 01:52:06 PST -------
Created an attachment (id=17105) [details]
Result with Firefox 2.0.0.9
------- Comment #4 From 2008-02-14 05:55:11 PST -------
Opera behaves identically as Webkit. 
------- Comment #5 From 2011-06-15 20:34:58 PST -------
I *think* WebKit gets this right, and Firefox wrong, as by using getComputedStyle you're dumping the CSS-specified values directly and not a derived value.  However I'm not sufficiently sure to close this bug, so I'll email www-style to ask for an answer as to which is the correct behaviour.

Regardless of the answer to this, the inspector's behavior is clearly incorrect and should have a bug filed against it.
------- Comment #6 From 2011-10-19 21:08:22 PST -------
Firefox is wrong.  When "box-sizing:border-box" is set, the 'width' and 'height' properties control the size of the border box, not the content box.  Thus, our behavior (of returning the size of the border box) is correct.