Canvas in HTML5

<canvas>  element in HTML5 is used to draw graphics using scripting.  <canvas> element is just a container for the graphics and it cannot draw anything of its own. We must use scripts such as Javascript to draw objects and to perform animations.

<canvas> element must have an  id attribute to reference it in script file. In addition to  id  attribute, we have to specify the width and height attribute in order to define the size of the canvas.

Following code snippet creates a simple  <canvas>  element. By default, the canvas doesn’t have a border or content.

Leave a Reply