<html> <head> <title>canvas</title> <script type="text/javascript"> function sample() { var canvas = document.getElementById('samplex'); var context = canvas.getContext('2d'); context.fillRect(20,20,200,200); context.fillStyle = 'rgb(255,00,00)'; context.fill(); } </script> </head> <body onLoad="sample()"> <canvas id="samplex"> </canvas> </body> </html>