The Document Object Model

HTML and JavaScript are very different languages. One is a declarative markup language and the other object-oriented scripting language. Yet the two languages work together, thanks in large part to the Document Object model.

The Document Object Modelopen in new window (DOM) is a programming interface for HTML documents, like a web page. It provides a representation of the page so that programs can change the document structure style and content. Typically, these programs are written in JavaScript.

Because all modern browsers have implemented a variation of the DOM standard, there are no special requirements needed to start using the DOM, and many of the commonly used commands are supported by a majority of the browsers. When working with the DOM, the document and window elements are immediately available to manipulate the document and its children.

Some of the properties we can access of the document object are:

PropertyDescription
document.titleContains the title of the current document
document.lastModifiedContains the date when the document was last modified
document.URLContains the URL of the current document
document.domainContains the domain of the current document
document.cookieContains a list of all the cookies for the document
document.formsContains the list of all the forms in the document
document.imagesContains a list of all the images in the document
document.linksContains the list of all the links in the document

This YouTube video was created by Steve Griffith.