How to Use the Html5 Canvas Tag

by Coder0806 in Circuits > Computers

651 Views, 4 Favorites, 0 Comments

How to Use the Html5 Canvas Tag

img.png

The html5 canvas is not different from the other html canvases.Such as : <p>Text</p>. It has the same build and shape and it looks like this : <canvas> </canvas>. When using the html5 canvas tag there are a few attributes you must use like : <canvas id="canvas" width="400" height="400"></canvas>. Now to import the html5 canvas into js so you can draw shapes and text. The code looks like this :

var c = document.getElementById("canvas");
var ctx = c.getContext("2d");

Now you can learn to draw shapes in the next tutorial see you next time.