First things first! The
document allows you to access the root node of the DOM tree. Before you can access a specific element in the page, first you must access the document structure itself. The
document allows scripts to access children of the DOM as properties.
For example, if you wanted to access the
<body> element in your script, you could access it as a property of the
document by typing
document.body. This property will return the body element of that DOM.
Similarly, you could access the
<title> element with the
.title property. See a comprehensive list of all
The diagram to the right illustrates that the
document keyword points to the root node of the Document Object Model (DOM). The
document.head properties act as though you were directly accessing the
html DOM element. Click Next when you’re ready!