- ✕This summary was generated using AI based on multiple online sources. To view the original source information, use the "Learn more" links.
The HTML <canvas> element is a powerful tool for drawing graphics on a web page. It allows you to create and manipulate 2D shapes, text, images, and even animations using JavaScript. The canvas itself is a rectangular area defined in your HTML, and you use JavaScript to draw on it.
Basic Setup
To start drawing on a canvas, you need to include the <canvas> element in your HTML and use JavaScript to access its rendering context. Here is a simple example:
<!DOCTYPE html><html><body><canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;"></canvas><script>const canvas = document.getElementById("myCanvas");const ctx = canvas.getContext("2d");// Draw a red rectanglectx.fillStyle = "red";ctx.fillRect(0, 0, 150, 75);</script></body></html>Copied!✕Copy HTML Canvas Drawing - W3Schools
Drawing graphics - Learn web development | MDN
Jan 25, 2026 · The browser contains some very powerful graphics programming tools, from the Scalable Vector Graphics (SVG) language, to APIs for drawing on …
How to Draw with JavaScript on an HTML Canvas …
Feb 8, 2024 · For a deep dive, read the full tutorial where we build up a complete game with plain JavaScript. In this tutorial, we not only cover how to draw the …
JavaScript Canvas
The 2D rendering context allows you to draw shapes, text, images, and other objects. The following example shows how to select the canvas element using …
Build A Drawing App using JavaScript - GeeksforGeeks
Jul 23, 2024 · A drawing app that lets us draw shapes like triangles, circles, and rectangles which can be made using HTML, CSS, and JavaScript. We'll also have …
- Watch full videoWatch full video
Mastering JavaScript for Canvas: A Comprehensive …
Whether you're a beginner in JavaScript or looking to refine your skills, this article will guide you through detailed examples and comprehensive explanations on …
Canvas API - Web APIs | MDN - MDN Web Docs
Jul 17, 2025 · The Canvas API provides a means for drawing graphics via JavaScript and the HTML <canvas> element. Among other things, it can be used for animation, game graphics, data …
Draw and Animate Using the Canvas API in JavaScript
Dec 12, 2024 · It comes with a range of methods and properties that can help you achieve various drawing and animation tasks. In this guide, we will walk you through creating a basic drawing and …
js-draw - npm
It's possible for applications using js-draw to add custom pen types that can also be customized in this way. It's also possible to save the toolbar state and restore it …
JavaScript - Canvas - Online Tutorials Library
The HTML <canvas> element can be used to create and draw graphics on the web page. It can draw various graphics or shapes, like lines, circles, etc., on the web page and animate them.