<html> <head> <title>canvas</title> <script type="text/javascript"> function sample() { var canvas = document.getElementById('samplex'); var ctx = canvas.getContext('2d'); ctx.beginPath(); ctx.fillRect(50,50,5,400); ctx.fillRect(50,450,400,5); ctx.stroke(); } </script> </head> <body onLoad="sample()"> <canvas id="samplex" width="500" height="500"> </canvas> </body> </html>