<canvas id="canvas1" width="300" height="200" 
    style="background: whitesmoke;"></canvas>
<script>
    var c=document.getElementById("canvas1");
    //Lấy context
    var ctx=c.getContext("2d");
  ctx.fillRect(20,20,100,100);
</script>

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.