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, and implements those from DocumentAndElementEventHandlers, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrForeignElement and TouchEventHandlers.
HTMLElement.accessKey- Is a
DOMStringrepresenting the access key assigned to the element. HTMLElement.accessKeyLabelRead only- Returns a
DOMStringcontaining the element's assigned access key. HTMLElement.contentEditable- Is a
DOMString, where a value oftruemeans the element is editable and a value offalsemeans it isn't. HTMLElement.isContentEditableRead only- Returns a
Booleanthat indicates whether or not the content of the element can be edited. HTMLElement.contextMenu- Is a
HTMLMenuElementrepresenting the contextual menu associated with the element. It may benull. HTMLOrForeignElement.datasetRead only- Returns a
DOMStringMapwith which script can read and write the element's custom data attributes (data-*) . HTMLElement.dir- Is a
DOMString, reflecting thedirglobal attribute, representing the directionality of the element. Possible values are"ltr","rtl", and"auto". HTMLElement.draggable- Is a
Booleanindicating if the element can be dragged. HTMLElement.enterkeyhint- Is a
DOMStringdefining what action label (or icon) to present for the enter key on virtual keyboards. HTMLElement.hidden- Is a
Booleanindicating if the element is hidden or not. HTMLElement.inert- Is a
Booleanindicating 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- 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- Is a
Booleanrepresenting the item scope. HTMLElement.itemTypeRead only- Returns a
DOMSettableTokenList… HTMLElement.itemId- Is a
DOMStringrepresenting the item ID. HTMLElement.itemRefRead only- Returns a
DOMSettableTokenList… HTMLElement.itemPropRead only- Returns a
DOMSettableTokenList… HTMLElement.itemValue- Returns a
Objectrepresenting the item value. HTMLElement.lang- Is a
DOMStringrepresenting the language of an element's attributes, text, and element contents. HTMLElement.noModule- Is a
Booleanindicating whether an import script can be executed in user agents that support module scripts. HTMLOrForeignElement.nonce- 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.offsetHeightRead only- Returns a
doublecontaining the height of an element, relative to the layout. HTMLElement.offsetLeftRead only- Returns a
double, the distance from this element's left border to itsoffsetParent's left border. HTMLElement.offsetParentRead only- Returns a
Elementthat is the element from which all offset calculations are currently computed. HTMLElement.offsetTopRead only- Returns a
double, the distance from this element's top border to itsoffsetParent's top border. HTMLElement.offsetWidthRead only- Returns a
doublecontaining the width of an element, relative to the layout. HTMLElement.propertiesRead only- Returns a
HTMLPropertiesCollection… HTMLElement.spellcheck- Is a
Booleanthat controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them. ElementCSSInlineStyle.style- Is a
CSSStyleDeclaration, an object representing the declarations of an element's style attributes. HTMLOrForeignElement.tabIndex- Is a
longrepresenting the position of the element in the tabbing order. HTMLElement.title- Is a
DOMStringcontaining the text that appears in a popup box when mouse is over the element. HTMLElement.translate- Is a
Booleanrepresenting the translation.
Event handlers
Most event handler properties, of the form onXYZ, are defined on the DocumentAndElementEventHandlers, GlobalEventHandlers or TouchEventHandlers interfaces and implemented by HTMLElement. In addition, the following handlers are specific to HTMLElement.
HTMLElement.oncopy- Returns the event handling code for the
copyevent (bug 280959). HTMLElement.oncut- Returns the event handling code for the
cutevent (bug 280959). HTMLElement.onpaste- Returns the event handling code for the
pasteevent (bug 280959). TouchEventHandlers.ontouchstart- Returns the event handling code for the
touchstartevent. TouchEventHandlers.ontouchend- Returns the event handling code for the
touchendevent. TouchEventHandlers.ontouchmove- Returns the event handling code for the
touchmoveevent. TouchEventHandlers.ontouchenter- Returns the event handling code for the
touchenterevent. TouchEventHandlers.ontouchleave- Returns the event handling code for the
touchleaveevent. TouchEventHandlers.ontouchcancel- Returns the event handling code for the
touchcancelevent.
Methods
Inherits methods from its parent, Element, and implements those from DocumentAndElementEventHandlers, ElementCSSInlineStyle, GlobalEventHandlers, HTMLOrForeignElement and TouchEventHandlers.
HTMLElement.attachInternals()- Attaches an
ElementInternalsinstance to the custom element. HTMLOrForeignElement.blur()- Removes keyboard focus from the currently focused element.
HTMLElement.click()- Sends a mouse click event to the element.
HTMLOrForeignElement.focus()- Makes the element the current keyboard focus.
HTMLElement.forceSpellCheck()- Runs the spell checker on the element's contents.
Events
Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.
Animation events
animationcancel- Fired when an animation unexpectedly aborts.
Also available via theonanimationcancelproperty. animationend- Fired when an animation has completed normally.
Also available via theonanimationendproperty. animationiteration- Fired when an animation iteration has completed.
Also available via theonanimationiterationproperty. animationstart- Fired when an animation starts.
Also available via theonanimationstartproperty.
Input events
beforeinput- Fired when the value of an
<input>,<select>, or<textarea>element is about to be modified. input- Fired when the
valueof an<input>,<select>, or<textarea>element has been changed.
Also available via theoninputproperty. change- Fired when the
valueof an<input>,<select>, or<textarea>element has been changed and committed by the user. Unlike theinputevent, thechangeevent is not necessarily fired for each alteration to an element'svalue.
Pointer events
gotpointercapture- Fired when an element captures a pointer using
setPointerCapture().
Also available via theongotpointercaptureproperty. lostpointercapture- Fired when a captured pointer is released.
Also available via theonlostpointercaptureproperty. pointercancel- Fired when a pointer event is canceled.
Also available via theonpointercancelproperty. pointerdown- Fired when a pointer becomes active.
Also available via theonpointerdownproperty. pointerenter- Fired when a pointer is moved into the hit test boundaries of an element or one of its descendants.
Also available via theonpointerenterproperty. pointerleave- Fired when a pointer is moved out of the hit test boundaries of an element.
Also available via theonpointerleaveproperty. pointermove- Fired when a pointer changes coordinates.
Also available via theonpointermoveproperty. pointerout- Fired when a pointer is moved out of the hit test boundaries of an element (among other reasons).
Also available via theonpointeroutproperty. pointerover- Fired when a pointer is moved into an element's hit test boundaries.
Also available via theonpointeroverproperty. pointerup- Fired when a pointer is no longer active.
Also available via theonpointerupproperty.
Transition events
transitioncancel- Fired when a CSS transition is canceled.
Also available via theontransitioncancelproperty. transitionend- Fired when a CSS transition has completed.
Also available via theontransitionendproperty. transitionrun- Fired when a CSS transition is first created.
Also available via theontransitionrunproperty. transitionstart- Fired when a CSS transition has actually started.
Also available via theontransitionstartproperty.
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 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 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

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.
