Horje

How to create HTML <canvas> Tag

Draw a red rectangle on the fly, and show it inside the <canvas> element:
index.html
Example: HTML
 <canvas id="myCanvas">
Your browser does not support the canvas tag.
</canvas>

<script>
let canvas = document.getElementById("myCanvas");
let ctx = canvas.getContext("2d");
ctx.fillStyle = "#FF0000";
ctx.fillRect(0, 0, 80, 80);
</script> 

Output should be:

How to create HTML <canvas> Tag




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin