HTML <canvas> Tag
- Description:
-
The HTML <canvas> tag is used for creating graphics on the fly. It can be used for rendering graphs, game graphics, or other visual images.
Any text inside the <canvas> element will be displayed in browsers that does not support <canvas>.
- Example Code:
-
<canvas id="canvasTest">Your browser does not support the HTML5 canvas tag.</canvas>
<script type="text/javascript">
var canvas=document.getElementById('canvasTest');
var ctx=canvas.getContext('2d');
ctx.fillStyle='#800000';
ctx.fillRect(0,0,100,100);
</script> - Result:
-
- Attributes:
-
Attribute Definition height Specifies the canvas height in pixels width Specifies the canvas width in pixels - Global Attributes:
-
The <canvas> tag also supports the Global Attributes in HTML5
- Event Attributes:
-
The <canvas> tag also supports the Event Attributes in HTML5