A <canvas> element with a height and width of 200 pixels:
More "Try it Yourself" examples below.
The height attribute specifies the height of the <canvas> element, in pixels.
Tip: Use the width attribute to specify the width of the <canvas> element, in pixels.
Tip: Each time the height or width of a canvas is re-set, the canvas content will be cleared (see example at bottom of page).
Tip: Learn more about the <canvas> element in our HTML Canvas Tutorial.
The numbers in the table specify the first browser version that fully supports the attribute.
Attribute | |||||
---|---|---|---|---|---|
height | 4.0 | 9.0 | 2.0 | 3.1 | 9.0 |
The <canvas> tag is new in HTML5.
Value | Description |
---|---|
pixels | Specifies the height of the canvas, in pixels (e.g. "100"). Default height is "150" |
Clear the canvas by setting the width or height attribute (using JavaScript):