HTML CANVAS Tag || CANVAS Tag in HTML
×

HTML CANVAS <canvas> Tag

0 447

Canvas is an HTML5 element, which is used to draw graphics for the dynamic, scriptable rendering of 2D and 3D shapes and bitmap images on the web page.

In Canvas, we need the script to draw the graphics. It provides an empty graphic zone on which specific JavaScript APIs can draw (such as Canvas 2D or WebGL).

Note:

Any text written inside the <canvas> element will be displayed in browsers that do not support in <canvas>.

Program:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>HTML Canvas Tag</title>
</head>
<body>

<h1>HTML Canvas Tag</h1>

<canvas id="myCanvasid">Your browser does not support the HTML5 Canvas Tag.</canvas>

<script>
var c = document.getElementById("myCanvasid");
var ctx = c.getContext("2d");
ctx.fillStyle = "#000";
ctx.fillRect(0, 0, 80, 100);
</script>
</body>
</html>


Share:


Leave a Reply


Comments
    Waiting for your comments