Why box-sizing is not working with width/height attribute on canvas element?

As a guess, I’d say it was this paragraph from the spec.

When its canvas context mode is none, a canvas element has no rendering context, and its bitmap must be fully transparent black with an intrinsic width equal to the numeric value of the element’s width attribute and an intrinsic height equal to the numeric value of the element’s height attribute, those values being interpreted in CSS pixels, and being updated as the attributes are set, changed, or removed.

That is the bitmap must be taken from the height and width attributes. Box-sizing plays no part.

Note also that the HTML5 rendering section says that:

The width and height attributes on embed, iframe, img, object or video elements, and input elements with a type attribute in the Image Button state and that either represents an image or that the user expects will eventually represent an image, map to the dimension properties width and height on the element respectively.

Canvas is not mentioned there.

Leave a Comment