Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. 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 rectangle
    ctx.fillStyle = "red";
    ctx.fillRect(0, 0, 150, 75);
    </script>

    </body>
    </html>
    Copied!
    Feedback
  2. HTML Canvas Drawing - W3Schools

    The drawing on the canvas is done with JavaScript. The canvas is initially blank. To display something, a script is needed to access the rendering context and draw on it. T…
    Step 1: Find The Canvas Element

    First of all, you must find the <canvas>element. You access a <canvas> element with the HTML DOM method getElementById():

    Step 2: Create A Drawing Object

    Secondly, you need a drawing object for the canvas. The getContext()method returns an object with tools (properties and methods) for drawing:

  3. 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 …

  4. 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 …

  5. 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 …

  6. 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 …

  7. 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 …

  8. 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 …

  9. 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 …

  10. 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 …

  11. 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.