- 2

Weill some kind person tell me what is wrong with this code?

What is wrong with this code? </body> </html> var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100); <!DOCTYPE html> <html>

7th Jul 2019, 7:58 PM
PeculiarP
PeculiarP - avatar
2 odpowiedzi
+ 1
For starters, that's not how html works. What you wrote is fully nonsensical. If you want javascript inside you html file, you should do it like this: <html> <head> ... </head> <body> ... <script> ... </script> </body> </html>
7th Jul 2019, 8:10 PM
Airree
Airree - avatar
0
All wrong. <!DOCTYPE html> <body> <canvas id="canvas1"></canvas> <script> var c=document.getElementById("canvas1"); var ctx=c.getContext("2d"); ctx.fillRect(20,20,100,100); </script> </body> </html> https://www.sololearn.com/learn/HTML/2201/
7th Jul 2019, 8:22 PM
Solo
Solo - avatar