How do you clear the screen in HTML? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How do you clear the screen in HTML?

This is my code. <!DOCTYPE html> <html> <head> <h1>Hello</h1> <body bgcolor="red"> <p1>H</p1> <p1>Ha</p1> <p1>Hav</p1> <p1>Have</p1> <p1>Have a</p1> <p1>Have a h</p1> <p1>Have a ha</p1> <p1>Have a hap</p1> <p1>Have a happ</p1> <p1>Have a happy</p1> <p1>Have a happy n</p1> <p1>Have a happy ne</p1> <p1>Have a happy new</p1> <p1>Have a happy new y</p1> <p1>Have a happy new ye</p1> <p1>Have a happy new yea</p1> <p1>Have a happy new year</p1> <p1>Have a happy new year!</p1> </html>

22nd Dec 2019, 12:05 PM
Amitoj Singh
Amitoj Singh - avatar
2 Answers
+ 2
If by "clear" you mean to remove existing content of page then here is JS way: document.body.innerHTML=""; it'll overwrite everything from page. HTML can't do that :) if this isn't what you wanted to ask , please edit your question and add some more description.
22nd Dec 2019, 12:38 PM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 1
Need to fix these before using JS * Close your <head> with </head> * Move <h1>Hello</h1> inside body * Replace <p1> with <p>, and </p1> with </p> * Close your <body> with </body>, before the </html>
22nd Dec 2019, 12:42 PM
Ipang