Why won't my canvas work? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why won't my canvas work?

I was trying to set up an HTML5 canvas for a new code, like I have done many times, but for some reason it won't work. Why? https://code.sololearn.com/WfOeQT6BNS1t/?ref=app

10th Jul 2023, 12:22 PM
Paxton Programer
5 Answers
+ 4
1. your code does not have a <body> 2. when the height of the body is not defined, the body is only the height that just fits the contents – which is not necessarily the screen size. suggestion: make a proper <body>, give the body a fixed size that is as large as the screen.
10th Jul 2023, 12:40 PM
Lisa
Lisa - avatar
+ 1
How do I apply a fixed size?
10th Jul 2023, 6:21 PM
Paxton Programer
+ 1
Thanks
11th Jul 2023, 9:48 PM
Paxton Programer
0
For instance body { width: 100vw; height: 100vh; }
10th Jul 2023, 6:26 PM
Lisa
Lisa - avatar
0
Follow what Lisa mentioned, also, I hsve spotted an error in your HTML file, you have made a typo in the closing tag of body, it should be </body> instead of <body/>.
12th Jul 2023, 1:26 AM
Danish Zubair
Danish Zubair - avatar