Code
Execute
<!DOCTYPE html> <html> <head> <title> Wikitechy HTML Canvas rect</title> </head> <body> <h2>HTML Canvas rect with example</h2> <canvas id="myCanvas" width="370" height="200" style="border:1px solid blue;"> </canvas> <script> var a = document.getElementById("myCanvas"); var context = a.getContext("2d"); context.rect(90, 50, 170, 100); context.strokeStyle="green"; context.stroke(); </script> </body> </html>
Result