HTML canvas Tag Last Updated : 11 Jul, 2025 Comments Improve Suggest changes 8 Likes Like Report 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. HTML <!DOCTYPE html> <html> <body> <canvas id="GeeksforGeeks" width="200" height="100" style="border:1px solid black"> </canvas> </body> </html> 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:AttributesDescriptionsheightThis attribute is used to set the height of the canvas by taking the value in pixels and its default value is 150.widthThis 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 HTML <!DOCTYPE html> <html> <body> <canvas id="geeks" height="200" width="200" style="border:1px solid black"> </canvas> <script> let c = document.getElementById("geeks"); let cx = c.getContext("2d"); cx.beginPath(); cx.arc(100, 100, 90, 0, 2 * Math.PI); cx.stroke(); </script> </body> </html> More Example HTML <!DOCTYPE html> <html> <body> <canvas id="geeks" width="200" height="200" style="border:1px solid black"> </canvas> <script> let c = document.getElementById("geeks"); let cx = c.getContext("2d"); let grd = cx.createRadialGradient (100, 100, 5, 100, 100, 100); grd.addColorStop(0, "red"); grd.addColorStop(1, "green"); cx.fillStyle = grd; cx.fillRect(0, 0, 200, 200); </script> </body> </html> Comment S sheyakhare1999 Follow 8 Improve S sheyakhare1999 Follow 8 Improve Article Tags : Technical Scripter Web Technologies HTML HTML-Tags Explore HTML BasicsHTML Introduction5 min readHTML Editors5 min readHTML Basics7 min readStructure & ElementsHTML Elements5 min readHTML Attributes8 min readHTML Headings4 min readHTML Paragraphs5 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists5 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks3 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables10 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics6 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List15+ min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like