Javascript Reference - HTML DOM Element Objects

In the HTML DOM (Document Object Model), everything is a node.

The Element object represents an HTML element.

Browser Support

Elements Yes Yes Yes Yes Yes

Properties and Methods

The following properties and methods can be used on all HTML elements.

Property / Method Description
element. Sets or gets the accesskey for an element
element.addEventListener() Attaches an event handler to an element
element.appendChild() Adds a new child node to an element as the last child node
element.attributes Get a NamedNodeMap of an element's attributes
element.blur() Removes focus from an element
element.childNodes Get a NodeList of child nodes for an element
element.className Sets or gets the class attribute of an element Simulates a mouse-click on an element
element.clientHeight Get the viewable height of an element
element.clientWidth Get the viewable width of an element
element.cloneNode() Clones an element
element.compareDocumentPosition() Compares the document position of two elements
element.contentEditable Sets or gets whether the content of an element is editable or not
element.dir Sets or gets the text direction of an element
element.firstChild Get the first child of an element
element.focus() Gives focus to an element
element.getAttribute() Get the specified attribute value of an element node
element.getAttributeNode() Get the specified attribute node
element.getElementsByClassName() Get a list of all child elements with the specified class name
element.getElementsByTagName() Get a list of all child elements with the specified tagname
element.getFeature() Get an object which implements the APIs of a specified feature
element.getUserData() Get the object associated to a key on an element
element.hasAttribute() if an element has the specified attribute
element.hasAttributes() if an element has any attributes
element.hasChildNodes() if an element has any child nodes Sets or gets the id attribute of an element
element.innerHTML Sets or gets the content of an element
element.insertBefore() Inserts a new child node before a specified existing child node
element.isContentEditable if the content of an element is editable
element.isDefaultNamespace() if a specified namespaceURI is the default otherwise false
element.isEqualNode() Checks if two elements are equal
element.() Checks if two elements are the same node
element.isSupported() if a specified feature is supported on the element
element.lang Sets or gets the language code for an element
element.lastChild Get the last child of an element
element.namespaceURI Get the namespace URI of an element
element.nextSibling Get the next node at the same node tree level
element.nodeName Get the name of an element
element.nodeType Get the node type of an element
element.nodeValue Sets or gets the value of an element
element.normalize() Joins adjacent text nodes and removes empty text nodes in an element
element.offsetHeight Get the height of an element
element.offsetWidth Get the width of an element
element.offsetLeft Get the horizontal offset position of an element
element.offsetParent Get the offset container of an element
element.offsetTop Get the vertical offset position of an element
element.outerHTML Get the html representation of the element
element.ownerDocument Get the root element (document object) for an element
element.parentNode Get the parent node of an element
element.previousSibling Get the previous element at the same node tree level
element.querySelector() Get the first child element that matches a specified CSS selector(s) of an element
element.querySelectorAll() Get a static NodeList containing all child elements that matches a specified CSS selector(s) of an element
element.removeAttribute() Removes a specified attribute from an element
element.removeAttributeNode() Removes a specified attribute node, and Get the removed node
element.removeChild() Removes a child node from an element
element.replaceChild() Replaces a child node in an element
element.removeEventListener() Removes an event handler that has been attached with the addEventListener() method
element.scrollHeight Get the entire height of an element
element.scrollLeft Get the distance between the left edge of an element and the view
element.scrollTop Get the distance between the top edge of an element and the view
element.scrollWidth Get the entire width of an element
element.setAttribute() Sets or changes the specified attribute, to the specified value
element.setAttributeNode() Sets or changes the specified attribute node
element.setUserData() Associates an object to a key on an element Sets or gets the style attribute of an element
element.tabIndex Sets or gets the tab order of an element
element.tagName Get the tag name of an element
element.textContent Sets or gets the textual content of a node and its descendants
element.title Sets or gets the title attribute of an element
element.toString() Converts an element to a string
nodelist.item() Get the node at the specified index in a NodeList
nodelist.length Get the number of nodes in a NodeList