HMTL5 Canvas tag example for drawing rectangle | How create rectangle on webpage using canvas tag in html5

Before going through this article check canvas tag supported browsers list. Canvas tag is useful for drawing pictures on the webpage. In the below example i have shown, how to draw a rectangle on the webpage using plain HTML5 with java script. Canvas tag will take help of java script for drawing pictures.

<html>
<head>
    <title></title>
    <script type="text/javascript">
        function drawing() {
            var canvasid = document.getElementById('frmcanvas');
            var area = canvasid.getContext("2d");
            area.fillRect(30, 30, 200, 200);
        }
    </script>
</head>
<body onload="drawing()">
<canvas id="frmcanvas" width="300" height="300">
your browser don't support canvas html tag
</canvas>
</body>
</html>


Output: 

Share this post :

Post a Comment

Please give your valuable feedback on this post. You can submit any ASP.NET article here. We will post that article in this website by your name.

 
Support : Ranga Rajesh Kumar
Copyright © 2012. ASP.NET Examples - All Rights Reserved
Site Designed by Ranga Rajesh Kumar