<html> <head> <title>HTML 5 Canvas rect</title> </head> <body> <canvas id="c" width="400" height="300"></canvas> </body> <script type="text/javascript"> var c = document.getElementById('c'); var ctx = c.getContext('2d'); // draw rectangle via strokeRect() method ctx.rect(0, 0, 100, 100); //set time out, the rectngle will be drawed out after 5 secs. setTimeout(function () { ctx.stroke() }, 5000) </script> </html>