JavaScript Display Possibilities

JavaScript can "display" data in different ways and here we discuss innerHTML and document.write.

  • Writing into an HTML element, using innerHTML.
  • Writing into the HTML output using document.write().


Using innerHTML

To access an HTML element, JavaScript can use the document.getElementById(id) method. The id attribute defines the HTML element. The innerHTML property defines the HTML content:


Using document.write()

For testing purposes, it is convenient to use document.write():

The write() method writes HTML expressions or JavaScript code to a document. The write() method is mostly used for testing: If it is used after an HTML document is fully loaded, it will delete all existing HTML.



Write some text directly to the HTML document, with a new line after each statement (using <br>):

document.write("Hello World! <br>");
document.write("Have a nice day!");


Write HTML elements with text directly to the HTML document:???

document.write("<h1>Hello World!</h1><p>Have a nice day!</p>");


Write the Date object directly to the HTML:


Contact Details

Mobile Number : 9891 222 738, 9891 50 1300

E-mail :

ADDRESS: 263, First Floor,Pocket H-17, Sector 7,
Near Rohini West Metro Station, Rohini, Delhi - 110085
Opposite Metro Pillar No. 425

Working hours


Day Timing
Monday To Friday 8:00 Am To 8:00Pm
Saturday & Sunday 8:00 Am To 5:00Pm

Contact Information
ADDRESS: 263, First Floor
Pocket H-17, Sector 7,
Rohini, Delhi - 110085
Near Rohini West Metro Station
Opposite Metro Pillar No. 425
Ansal Sushant City, Kundli,
Distt. Sonipat, Haryana, India

Near Panipat, Karnal


Mobile Number: