<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.
//Simple canvas element demo in html5
<title>HTML 5 Canvas</title>
border:2px solid #ff0000;
<canvas id="myCanvas" width="200px" height="300px"></canvas>