Search code examples
htmlcsscanvasarea

What is canvas in HTML 5?


What is canvas in HTML 5? I'm a little new as a developer. Canvas is an HTML area on which you can draw graphics.

""500"" id=""mycanvas"" solid="" style=""border:1px" width=""600""></canvas>

var c=document.getElementById("mycanvas");
var ctx=c.getContext("2d"); 

What does it mean?


Solution

  • canvas in HTML 5

    The HTML element is used to draw graphics, on the fly, via JavaScript.

    The element is only a container for graphics. You must use JavaScript to actually draw the graphics.

    Canvas has several methods for drawing paths, boxes, circles, text, and adding images.

    check this link

    I'm added an example below,

    <canvas id="myCanvas" width="200" height="100" style="border:1px solid #000000;">
    Your browser does not support the HTML5 canvas tag.
    </canvas>