Update: <body style="margin:0"> <script> var canvas = document.createElement('canvas'); canvas.id = "mycanvas"; canvas.width = window.innerWidth; canvas.height = window.innerHeight; var body = document.getElementsByTagName("body")[0]; body.appendChild(canvas); var c = document.getElementById("mycanvas").getContext('2d'); c.fillRect(20,20,100,100); c.fillText("hello world", 200,200); </script> </body>