Html5 Simple Canvas Example - Html

How to create simple canvas using html5?

Snippet Code


  
Rate this page :
  [ 0 votes]

Canvas is generally known as a rectangular area on a html page. Normally the canvas has no border and no content. In canvas the rectangular page allows you to draw anything you want. The sample code to create canvas using html5 is given below.

<canvas id="myCanvas" width="200" height="100" style="border:1px solid #c3c3c3;"> </canvas> <script> var c = document.getElementById("myCanvas"); var ctx = c.getContext("2d"); ctx.fillStyle = "#FF0000"; ctx.fillRect(0,0,250,155); </script>

Tags


Ask Questions

Ask Question