Bug 15880 - computed style height and width reflect border box dimensions
Summary: computed style height and width reflect border box dimensions
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-11-07 01:44 PST by Marcus Better
Modified: 2011-10-19 21:08 PDT (History)
3 users (show)

See Also:


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 Marcus Better 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 Marcus Better 2007-11-07 01:46:36 PST
Created attachment 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 Marcus Better 2007-11-07 01:51:45 PST
Created attachment 17104 [details]
Result with WebKit r27433
Comment 3 Marcus Better 2007-11-07 01:52:06 PST
Created attachment 17105 [details]
Result with Firefox 2.0.0.9
Comment 4 Robert Blaut 2008-02-14 05:55:11 PST
Opera behaves identically as Webkit. 
Comment 5 Shane Stephens 2011-06-15 20:34:58 PDT
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 Tab Atkins 2011-10-19 21:08:22 PDT
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.