Example

A simple <canvas>:

Laboratory

description & Usage

<canvas> is used to draw graphics, via scripting (usually JavaScript).

<canvas> is currently most commonly used with JavaScript, which is the most common scripting language for HTML documents.

If the browser does not support the scripting language, the text inside the <canvas> tag is shown as an alternative.

Notes

note: <canvas> tag is transparent.

Browser compatibility and Support

# Chrome Edge Firefox Safari Opera
<canvas>

Attributes

Attributes Values Description
height
pixels
Determines the height of the corresponding tags on the right.
width
pixels
Determines the width of the corresponding elements on the right.

Global Attributes

The <canvas> tag supports the HTML Global Attributes.

Event Attributes

The <canvas> tag supports the HTML Event Attributes.

Default CSS

Most browsers will display the <canvas> tag with the following default style: