HTML DOM

HTML DOM Complete Reference

This is a quick reference of the most commonly used properties, methods, and collections of the document object in the HTML DOM. Use it as a cheat sheet when writing JavaScript that reads or updates the page.


About This Reference

The document object is the entry point to the DOM. Its members fall into three groups: properties (values you read or set), methods (actions you call), and collections (live lists of specific elements). The table below summarizes the members you will use most often.

ℹ️

Members ending with () are methods you call, like document.getElementById("x"). Members without () are properties or collections you access directly, like document.title or document.forms.

Document Properties, Methods, and Collections

NameDescription
activeElementReturns the element that currently has focus.
anchorsCollection of all <a> elements that have a name attribute.
baseURIReturns the absolute base URI of the document.
bodySets or returns the <body> element of the document.
characterSetReturns the character encoding of the document (e.g. UTF-8).
cookieSets or returns all cookies associated with the document.
createAttribute()Creates a new attribute node.
createComment()Creates a comment node with the given text.
createDocumentFragment()Creates an empty, lightweight DocumentFragment.
createElement()Creates a new element node with the given tag name.
createTextNode()Creates a new text node with the given text.
close()Closes an output stream opened with document.open().
defaultViewReturns the window object associated with the document.
designModeSets or returns whether the document is editable.
doctypeReturns the Document Type Declaration of the document.
documentElementReturns the root <html> element of the document.
documentURISets or returns the location (URI) of the document.
domainReturns the domain name of the server that loaded the document.
embedsCollection of all <embed> elements in the document.
formsCollection of all <form> elements in the document.
getElementById()Returns the element with the specified id.
getElementsByClassName()Returns a collection of elements with the given class name.
getElementsByName()Returns a collection of elements with the given name attribute.
getElementsByTagName()Returns a collection of elements with the given tag name.
headReturns the <head> element of the document.
imagesCollection of all <img> elements in the document.
implementationReturns the DOMImplementation object for the document.
importNode()Imports a node from another document into this one.
lastModifiedReturns the date and time the document was last modified.
linksCollection of all <a> and <area> elements that have an href.
open()Opens an output stream to collect document.write() output.
querySelector()Returns the first element matching a CSS selector.
querySelectorAll()Returns all elements matching a CSS selector.
readyStateReturns the loading status of the document.
referrerReturns the URL of the page that linked to this document.
scriptsCollection of all <script> elements in the document.
titleSets or returns the title of the document.
URLReturns the full URL of the document.
write()Writes HTML or JavaScript output to the document.
writeln()Writes to the document, followed by a newline character.

For a focused explanation of any single member, see its dedicated page in this HTML DOM section.

💡

Prefer querySelector and querySelectorAll for flexible CSS-selector-based lookups, and getElementById for fast, direct access by id.

Ready to use your HTML skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships