HTML DOM Element Objects

## JavaScript Reference

Overview

## JavaScript Objects

JS Array JS Boolean JS Date JS Math JS Number JS String JS RegExp JS Global

## Browser Objects

Window Navigator Screen History Location

## HTML DOM Objects

DOM Document DOM Elements DOM Attributes DOM Events

## HTML Objects

DOM Anchor DOM Area DOM Base DOM Body DOM Button DOM Form DOM Frame/IFrame DOM Frameset DOM Image DOM Input Button DOM Input Checkbox DOM Input File DOM Input Hidden DOM Input Password DOM Input Radio DOM Input Reset DOM Input Submit DOM Input Text DOM Link DOM Meta DOM Object DOM Option DOM Select DOM Style DOM Table DOM td / th DOM tr DOM Textarea

# The HTML DOM Element Object

« Previous
Next Reference »

## HTML DOM Nodes

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

- The document itself is a document node
- All HTML elements are element nodes
- All HTML attributes are attribute nodes
- Text inside HTML elements are text nodes
- Comments are comment nodes

## The Element Object

In the HTML DOM, the Element object represents an HTML element.

Element objects can have child nodes of type element nodes, text nodes, or comment nodes.

A NodeList object represents a list of nodes, like an HTML element's collection of child nodes.

Elements can also have attributes. Attributes are attribute nodes (See next chapter).

## Browser Support

The Element Object and the NodeList Object is supported in all major browsers.

## Properties and Methods

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

Property / Method | Description
--- | ---
element.accessKey | Sets or returns the accesskey for an element
element.appendChild() | Adds a new child node, to an element, as the last child node
element.attributes | Returns a NamedNodeMap of an element's attributes
element.childNodes | Returns a NodeList of child nodes for an element
element.className | Sets or returns the class attribute of an element
element.clientHeight | Returns the viewable height of an element
element.clientWidth | Returns the viewable width of an element
element.cloneNode() | Clones an element
element.compareDocumentPosition() | Compares the document position of two elements
element.dir | Sets or returns the text direction of an element
element.firstChild | Returns the first child of an element
element.getAttribute() | Returns the specified attribute value of an element node
element.getAttributeNode() | Returns the specified attribute node
element.getElementsByTagName() | Returns a collection of all child elements with the specified tagname
element.getFeature() | Returns an object which implements the APIs of a specified feature
element.getUserData() | Returns the object associated to a key on an element
element.hasAttribute() | Returns true if an element has the specified attribute, otherwise false
element.hasAttributes() | Returns true if an element has any attributes, otherwise false
element.hasChildNodes() | Returns true if an element has any child nodes, otherwise false
element.id | Sets or returns the id of an element
element.innerHTML | Sets or returns the content of an element
element.insertBefore() | Inserts a new child node before a specified, existing, child node
element.isDefaultNamespace() | Returns true if a specified namespaceURI is the default, otherwise false
element.isEqualNode() | Checks if two elements are equal
element.isSameNode() | Checks if two elements are the same node
element.isSupported() | Returns true if a specified feature is supported on the element
element.lang | Sets or returns the language code for an element
element.lastChild | Returns the last child of an element
element.namespaceURI | Returns the namespace URI of an element
element.nextSibling | Returns the next node at the same node tree level
element.nodeName | Returns the name of an element
element.nodeType | Returns the node type of an element
element.nodeValue | Sets or returns the value of an element
element.normalize() | Joins adjacent text nodes and removes empty text nodes in an element
element.offsetHeight | Returns the height of an element
element.offsetWidth | Returns the width of an element
element.offsetLeft | Returns the horizontal offset position of an element
element.offsetParent | Returns the offset container of an element
element.offsetTop | Returns the vertical offset position of an element
element.ownerDocument | Returns the root element (document object) for an element
element.parentNode | Returns the parent node of an element
element.previousSibling | Returns the previous element at the same node tree level
element.removeAttribute() | Removes a specified attribute from an element
element.removeAttributeNode() | Removes a specified attribute node, and returns the removed node
element.removeChild() | Removes a child node from an element
element.replaceChild() | Replaces a child node in an element
element.scrollHeight | Returns the entire height of an element
element.scrollLeft | Returns the distance between the left edge of an element and the view
element.scrollTop | Returns the distance between the top edge of an element and the view
element.scrollWidth | Returns 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.setIdAttribute() |
element.setIdAttributeNode() |
element.setUserData() | Associates an object to a key on an element
element.style | Sets or returns the style attribute of an element
element.tabIndex | Sets or returns the tab order of an element
element.tagName | Returns the tag name of an element
element.textContent | Sets or returns the textual content of a node and its descendants
element.title | Sets or returns the title attribute of an element
element.toString() | Converts an element to a string
nodelist.item() | Returns the node at the specified index in a NodeList
nodelist.length | Returns the number of nodes in a NodeList

« Previous
Next Reference »

## Your suggestion:

Your E-mail (optional):

Page address:

Description:

Close [X]

## Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

## WEB HOSTING

Best Web Hosting UK Reseller Hosting Wow! $5 SSD Hosting

## WEB BUILDING

Download XML Editor
FREE Website BUILDER FREE Website Creator

## WEB RESOURCES

Web Statistics Web Validation

## SHARE THIS PAGE