HTML
Example
Pass
<
canvas
id
=
"
myCanvas
"
canvas
<
script
type
=
"
text/javascript
"var canvas=document.getElementById('myCanvas'); var ctx=canvas.getContext('2d'); ctx.fillStyle='#FF0000'; ctx.fillRect(0,0,80,100);
script
Try it »
Browser support

IE 9, Firefox, Opera, Chrome, and Safari support
**Note:** IE 8 and earlier versions of IE browsers do not support
Tag Definition and Usage Notes
Differences between HTML 4.01 and HTML5
Tips and Notes
Note:
**Tip:** To learn about all the properties and methods of the canvas object, please refer toHTML Canvas Reference Manual.
property
New : New attribute in HTML5.
| property | Value | Description |
|---|---|---|
| heightNew | pixels | Specifies the height of the canvas. |
| widthNew | pixels | Specifies the width of the canvas. |