Code
Execute
<!DOCTYPE html> <html> <head> <title>Wikitechy HTML Canvas fillStyle</title> </head> <body> <h1>HTML Canvas fillStyle</h1> <canvas id="wikitechyCanvas" width="400" height="250" style="border:1px solid blue;"> </canvas> <script> var canvas = document.getElementById("wikitechyCanvas"); var context = canvas.getContext("2d"); context.fillStyle = "green"; context.fillRect(100, 70, 170, 110); </script> </body> </html>
Result