Javascript Reference - HTML DOM HTML Object

The HTML object represents an HTML <html> element.

Standard Properties and Events

The HTML object supports the standard properties and events.


We can access the <html> element by using getElementsByTagName().

<!DOCTYPE html>
<button onclick="myFunction()">test</button>
<!--  ww  w.ja v a  2 s  .  c  o m-->
<p id="demo"></p>

function myFunction() {
    var x = document.getElementsByTagName("HTML")[0].innerHTML;
    document.getElementById("demo").innerHTML = x;


The code above is rendered as follows: