document.write("
<html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>HTML5 Canvas Example</title> <style> canvas { border: 1px solid black; } </style> <script> function rectangle(){ var canvas = document.getElementById('myCanvas'); if (canvas.getContext) { var ctx = canvas.getContext('2d'); ctx.lineWidth = 5; ctx.strokeStyle = "#00FF00"; ctx.rect(30, 20, 40, 20); ctx.stroke(); } else { alert ("Your browser does not support the HTML5 canvas"); } } </script> </head> <body> <canvas id="myCanvas" width="500" height="400"></canvas> <script>rectangle();</script> </body> </html>