HTML <canvas> Tag
In this tutorial, we will learn about canvas tag in HTML with the help of examples.
Canvas tag <canvas> is used for creating graphics,
<canvas> tag is only a transparent container for graphics, you must use a script to draw the graphics and CSS for styling the <canvas> tag.
Note : <canvas> tag is mainly used for game development.
<canvas id = "Canvas">
Your browser does not support the canvas tag.
var canvas = document.getElementById("Canvas");
var ctx = canvas.getContext("2D");
ctx.fillStyle = "#0099ff";
|height||pixels||Specifies the height of the canvas|
|width||pixels||Specifies the width of the canvas|
Note : The default value for the attribute height is 150 and for the width is 300.
Canvas Tag support all the global attributes of HTML.
Canvas Tag support all the event attributes of HTML.
We hope that this tutorial helped you develop better understanding of the concept of canvas tag in HTML.
Keep Learning : )
In the next tutorial, you'll learn about HTML