what is the difference between document.write("<h1>hello world</h1>"); and <h1>hello world </h1> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

what is the difference between document.write("<h1>hello world</h1>"); and <h1>hello world </h1>

28th Jun 2016, 7:03 AM
Shubham Raja Shrivastava
Shubham Raja Shrivastava - avatar
3 Answers
+ 4
We use document.write to output any text to HTML page using javascript. Anything written inside,will be rendered in the same way as the normal HTML text will be.
28th Jun 2016, 6:18 PM
Shraddha -
Shraddha - - avatar
+ 3
The first one is printed using JavaScript. You wont need to do that unless you're practicing or it's part of a JavaScript application or something similar. The second one is just plain HTM and that's how you would usually do it.
28th Jun 2016, 1:13 PM
ZinC
ZinC - avatar
+ 1
thank you
28th Jun 2016, 6:35 PM
Shubham Raja Shrivastava
Shubham Raja Shrivastava - avatar