Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML canvas height attribute

HTML height property

HTML canvas Tag Reference HTML tag

Example

A canvas with a height and width of 200 pixels ():

<

canvas

id

=

"

myCanvas

"

width

=

"

200

"

height

=

"

200

"

style

=

"

border:1px solid

"

Try it »


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the height property.

Note: Internet Explorer 8 and earlier IE versions are not supported. tag.


Definition and Usage

The height attribute specifies the height of the element, in pixels.

Tip: Whenever the height or width of the canvas is reset, the canvas content is cleared (see the example at the bottom of the page).

Tip: Please see ourHTML Canvas Learn more about in the tutorial knowledge.


Differences between HTML 4.01 and HTML 5

is a new tag in HTML5.


Syntax

Attribute values

Value Description
pixels Specifies the height of the canvas in pixels (for example, "100px" or just "100"). The default is "150".

More examples

Clear the canvas
How to clear the canvas by resetting the width or height attribute (using JavaScript).


HTML canvas Tag Reference HTML tag