HTMLElement

The HTMLElement interface represents any HTML element. Some elements directly implement this interface, while others implement it via an interface that inherits it.

Properties

Inherits properties from its parent, Element (en-US), and implements those from GlobalEventHandlers (en-US) and TouchEventHandlers.

HTMLElement.accessKey (en-US)
Is a DOMString (en-US) representing the access key assigned to the element.
HTMLElement.accessKeyLabel (en-US) Read only
Returns a DOMString (en-US) containing the element's assigned access key.
HTMLElement.contentEditable (en-US)
Is a DOMString (en-US), where a value of "true" means the element is editable and a value of "false" means it isn't.
HTMLElement.isContentEditable (en-US) Read only
Returns a Boolean (en-US) that indicates whether or not the content of the element can be edited.
HTMLElement.contextMenu (en-US) This deprecated API should no longer be used, but will probably still work.
Is a HTMLMenuElement (en-US) representing the contextual menu associated with the element. It may be null.
HTMLElement.dataset (en-US) Read only
Returns a DOMStringMap (en-US) with which script can read and write the element's custom data attributes (data-*) .
HTMLElement.dir (en-US)
Is a DOMString (en-US), reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".
HTMLElement.draggable
Is a Boolean indicating if the element can be dragged.
HTMLElement.dropzone Read only
Returns a DOMSettableTokenList reflecting the dropzone global attribute and describing the behavior of the element regarding a drop operation.
HTMLElement.hidden (en-US)
Is a Boolean indicating if the element is hidden or not.
HTMLElement.inert (en-US)
Is a Boolean indicating whether the user agent must act as though the given node is absent for the purposes of user interaction events, in-page text searches ("find in page"), and text selection.
HTMLElement.innerText (en-US)
Represents the "rendered" text content of a node and its descendants. As a getter, it approximates the text the user would get if they highlighted the contents of the element with the cursor and then copied it to the clipboard.
HTMLElement.itemScope This is an experimental API that should not be used in production code.
Is a Boolean representing the item scope.
HTMLElement.itemType Read only This is an experimental API that should not be used in production code.
Returns a DOMSettableTokenList
HTMLElement.itemId This is an experimental API that should not be used in production code.
Is a DOMString (en-US) representing the item ID.
HTMLElement.itemRef Read only This is an experimental API that should not be used in production code.
Returns a DOMSettableTokenList
HTMLElement.itemProp Read only This is an experimental API that should not be used in production code.
Returns a DOMSettableTokenList
HTMLElement.itemValue This is an experimental API that should not be used in production code.
Returns a Object representing the item value.
HTMLElement.lang (en-US)
Is a DOMString (en-US) representing the language of an element's attributes, text, and element contents.
HTMLElement.noModule
Is a Boolean indicating wether an import script can be executed in user agents that support module scripts.
HTMLElement.nonce (en-US)
Returns the cryptographic number used once that is used by Content Security Policy to determine whether a given fetch will be allowed to proceed.
HTMLElement.offsetHeight (en-US) Read only This is an experimental API that should not be used in production code.
Returns a double containing the height of an element, relative to the layout.
HTMLElement.offsetLeft (en-US)Read only This is an experimental API that should not be used in production code.
Returns a double, the distance from this element's left border to its offsetParent's left border.
HTMLElement.offsetParent (en-US)Read only This is an experimental API that should not be used in production code.
Returns a Element (en-US) that is the element from which all offset calculations are currently computed.
HTMLElement.offsetTop (en-US)Read only This is an experimental API that should not be used in production code.
Returns a double, the distance from this element's top border to its offsetParent's top border.
HTMLElement.offsetWidth (en-US)Read only This is an experimental API that should not be used in production code.
Returns a double containing the width of an element, relative to the layout.
HTMLElement.properties Read only This is an experimental API that should not be used in production code.
Returns a HTMLPropertiesCollection
HTMLElement.spellcheck
Is a Boolean that controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them.
HTMLElement.style (en-US)
Is a CSSStyleDeclaration (en-US), an object representing the declarations of an element's style attributes.
HTMLElement.tabIndex (en-US)
Is a long representing the position of the element in the tabbing order.
HTMLElement.title (en-US)
Is a DOMString (en-US) containing the text that appears in a popup box when mouse is over the element.
HTMLElement.translate This is an experimental API that should not be used in production code.
Is a Boolean representing the translation.

Event handlers

Most event handler properties, of the form onXYZ, are defined on the GlobalEventHandlers (en-US) or TouchEventHandlers interfaces and implemented by HTMLElement. In addition, the following handlers are specific to HTMLElement.

HTMLElement.oncopy (en-US) This API has not been standardized.
Returns the event handling code for the copy event (bug 280959).
HTMLElement.oncut (en-US) This API has not been standardized.
Returns the event handling code for the cut event (bug 280959).
HTMLElement.onpaste (en-US) This API has not been standardized.
Returns the event handling code for the paste event (bug 280959).
TouchEventHandlers.ontouchstart This API has not been standardized.
Returns the event handling code for the touchstart (en-US) event.
TouchEventHandlers.ontouchend This API has not been standardized.
Returns the event handling code for the touchend (en-US) event.
TouchEventHandlers.ontouchmove This API has not been standardized.
Returns the event handling code for the touchmove (en-US) event.
TouchEventHandlers.ontouchenter This API has not been standardized.
Returns the event handling code for the touchenter event.
TouchEventHandlers.ontouchleave This API has not been standardized.
Returns the event handling code for the touchleave event.
TouchEventHandlers.ontouchcancel This API has not been standardized.
Returns the event handling code for the touchcancel (en-US) event.

Methods

Inherits methods from its parent, Element (en-US).

HTMLElement.blur() (en-US)
Removes keyboard focus from the currently focused element.
HTMLElement.click()
Sends a mouse click event to the element.
HTMLElement.focus() (en-US)
Makes the element the current keyboard focus.
HTMLElement.forceSpellCheck() (en-US) This is an experimental API that should not be used in production code.
Runs the spell checker on the element's contents.

Specifications

Specification Status Comment
CSS Object Model (CSSOM) View Module
The definition of 'HTMLElement' in that specification.
Working Draft Added the following properties: offsetParent, offsetTop, offsetLeft, offsetWidth, and offsetHeight.
HTML Living Standard
The definition of 'HTMLElement' in that specification.
Living Standard Added the following properties: translate, itemScope, itemType, itemId, itemRef, itemProp, properties, and itemValue.
Added the following method: forceSpellcheck().
Moved the onXYZ attributes to the GlobalEventHandlers (en-US) interface and added an inheritance from it.
HTML5
The definition of 'HTMLElement' in that specification.
Recommendation Added the following properties: dataset, hidden, tabindex, accessKey, accessKeyLabel, draggable, dropzone, contentEditable, isContentEditable, contextMenu, spellcheck, commandType, commandLabel, commandIcon, commandHidden, commandDisabled, commandChecked, style, and all the onXYZ properties.
Moved the id and className properties to the Element (en-US) interface.
Document Object Model (DOM) Level 2 HTML Specification
The definition of 'HTMLElement' in that specification.
Obsolete No change from Document Object Model (DOM) Level 2 HTML Specification
Document Object Model (DOM) Level 1 Specification
The definition of 'HTMLElement' in that specification.
Obsolete Initial definition.

Browser compatibility

BCD tables only load in the browser

See also