VOOZH about

URL: https://www.geeksforgeeks.org/html/html-canvas-tag/

⇱ HTML canvas Tag - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

HTML canvas Tag

Last Updated : 11 Jul, 2025

The <canvas> tag in HTML is used to draw graphics on a web page using JavaScript. It can be used to draw paths, boxes, texts, gradients, and adding images. By default, it does not contain borders and text. 

Syntax

<canvas id = "script"> Contents... </canvas>

Note: The <canvas> tag is new in HTML5.

Attributes

The <canvas> tag accepts two attributes which are described below:

Attributes

Descriptions

height

This attribute is used to set the height of the canvas by taking the value in pixels and its default value is 150.

width

This attribute is used to set the width of the canvas by taking the value in pixels and its default value is 300.

Use canvas tag with JavaScript


More Example

Comment