You are here : htmlHTML 5canvas

<canvas> - HTML 5

The tag is used to draw graphics, on the fly, via scripting (usually JavaScript).

The tag is only a container for graphics, you must use a script to actually draw the graphics.

Attributes :

  • ​height (pixels) - Specifies the height of the canvas
  • width (pixels) - Specifies the width of the canvas


<canvas id="myCanvas"></canvas>


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

Output / Return Value


Available only to HTML 5.

JavaScript must be enabled to use.

Alternatives / See Also