The HTMLElement interface represents any HTML element. Some elements directly implement this interface, others implement it via an interface that inherits it.
Inherits properties from its parent, Element, and implements those from GlobalEventHandlers and TouchEventHandlers.
HTMLElement.accessKeyDOMString representing the access key assigned to the element.HTMLElement.accessKeyLabel Read only
DOMString containing the element's assigned access key.HTMLElement.contentEditableDOMString, where a value of "true" means the element is editable and a value of "false" means it isn't.HTMLElement.isContentEditable Read only
Boolean that indicates whether or not the content of the element can be edited.HTMLElement.contextMenu
HTMLMenuElement representing the contextual menu associated with the element. It may be null.HTMLElement.dataset Read only
DOMStringMap with which script can read and write the element's custom data attributes (data-*) .HTMLElement.dirDOMString, reflecting the dir global attribute, representing the directionality of the element. Possible values are "ltr", "rtl", and "auto".HTMLElement.draggableBoolean indicating if the element can be dragged.HTMLElement.dropzone Read only
DOMSettableTokenList reflecting the dropzone global attribute and describing the behavior of the element regarding a drop operation.HTMLElement.hiddenBoolean indicating if the element is hidden or not.HTMLElement.inertBoolean 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.innerTextHTMLElement.itemScope
Boolean representing the item scope.HTMLElement.itemType Read only
DOMSettableTokenList…HTMLElement.itemId
DOMString representing the item ID.HTMLElement.itemRef Read only
DOMSettableTokenList…HTMLElement.itemProp Read only
DOMSettableTokenList…HTMLElement.itemValue
Object representing the item value.HTMLElement.langDOMString representing the language of an element's attributes, text, and element contents.HTMLElement.noModuleBoolean indicating wether an import script can be executed in user agents that support module scripts.HTMLElement.nonceHTMLElement.offsetHeight Read only
double containing the height of an element, relative to the layout.HTMLElement.offsetLeftRead only
double, the distance from this element's left border to its offsetParent's left border.HTMLElement.offsetParentRead only
Element that is the element from which all offset calculations are currently computed.HTMLElement.offsetTopRead only
double, the distance from this element's top border to its offsetParent's top border.HTMLElement.offsetWidthRead only
double containing the width of an element, relative to the layout.HTMLElement.properties Read only
HTMLPropertiesCollection…HTMLElement.spellcheckBoolean that controls spell-checking. It is present on all HTML elements, though it doesn't have an effect on all of them.HTMLElement.styleCSSStyleDeclaration, an object representing the declarations of an element's style attributes.HTMLElement.tabIndexlong representing the position of the element in the tabbing order.HTMLElement.titleDOMString containing the text that appears in a popup box when mouse is over the element.HTMLElement.translate
Boolean representing the translation.Most event handler properties, of the form onXYZ, are defined on the GlobalEventHandlers or TouchEventHandlers interfaces and implemented by HTMLElement. In addition, the following handlers are specific to HTMLElement.
HTMLElement.oncopy
copy event (bug 280959).HTMLElement.oncut
cut event (bug 280959).HTMLElement.onpaste
paste event (bug 280959).TouchEventHandlers.ontouchstart
touchstart event.TouchEventHandlers.ontouchend
touchend event.TouchEventHandlers.ontouchmove
touchmove event.TouchEventHandlers.ontouchenter
touchenter event.TouchEventHandlers.ontouchleave
touchleave event.TouchEventHandlers.ontouchcancel
touchcancel event.Inherits methods from its parent, Element.
HTMLElement.blur()HTMLElement.click()HTMLElement.focus()HTMLElement.forceSpellCheck()
| 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. |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | ? | Yes | 1 | ? | ? | ? |
accessKey |
17 | Yes | 5 | ? | ? | ? |
accessKeyLabel |
? | No | 8 | ? | ? | ? |
blur |
? | Yes | 5 | 9 | ? | ? |
click |
9
|
Yes | 3
|
Yes | Yes | Yes
|
contentEditable |
Yes | Yes | 3 | 5.5 | 9 | Yes |
contextMenu
|
? | Yes | 1 | ? | ? | ? |
dataset |
8 | Yes | 6 | 11 | 11 | ? |
dir |
? | Yes | 1 | ? | ? | ? |
draggable |
Yes | Yes | 2 | Yes | 12 | Yes |
dropzone |
? | Yes | 1 | ? | ? | ? |
focus |
? | Yes | 5 | 9 | ? | ? |
forceSpellCheck
|
No | No | No | No | No | ? |
hidden |
? | Yes | 1 | ? | ? | ? |
inert |
60 | Yes | ? | ? | 47 | ? |
isContentEditable |
? | Yes | 1 | ? | ? | ? |
itemId
|
No | No | 6 | No | 11 — 15 | ? |
itemProp
|
No | No | 6 | No | 11 — 15 | ? |
itemRef
|
No | No | 6 | No | 11 — 15 | ? |
itemScope
|
No | No | 6 | No | 11 — 15 | ? |
itemType
|
No | No | 6 | No | 11 — 15 | ? |
itemValue |
No | No | 6 | No | 11 — 15 | ? |
lang |
? | Yes | 1 | ? | ? | ? |
noModule |
60 | ? | ? | No | 47 | ? |
nonce |
Yes | Yes | ? | ? | ? | ? |
offsetHeight
|
? | Yes | 1 | Yes | ? | ? |
offsetLeft
|
? | Yes | 1 | Yes | ? | ? |
offsetParent
|
? | Yes | 1 | Yes | ? | ? |
offsetTop
|
? | Yes | 1 | Yes | ? | ? |
offsetWidth
|
? | Yes | 1 | Yes | ? | ? |
onModule |
60 | ? | ? | ? | 47 | ? |
oncopy
|
? | Yes | 3 | ? | ? | ? |
oncut
|
? | Yes | 3 | ? | ? | ? |
onpaste
|
? | Yes | 3 | ? | ? | ? |
outerText
|
Yes | Yes | No | Yes | Yes | Yes |
spellcheck |
? | Yes | 2 | ? | ? | ? |
style |
Yes | Yes | Yes
|
Yes | Yes | ? |
tabIndex |
? | Yes | 1 | ? | ? | ? |
title |
? | Yes | 1 | ? | ? | ? |
translate
|
No | No | No | No | No | ? |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | 4 | ? | ? | ? |
accessKey |
? | ? | Yes | 5 | ? | ? | ? |
accessKeyLabel |
? | ? | No | 8 | ? | ? | ? |
blur |
? | ? | Yes | 5 | ? | ? | ? |
click |
Yes
|
Yes | Yes | 5 | Yes | Yes
|
? |
contentEditable |
Yes | Yes | Yes | 4 | Yes | Yes | ? |
contextMenu
|
Yes | Yes | Yes | 4 | ? | ? | ? |
dataset |
? | ? | Yes | 6 | ? | ? | ? |
dir |
Yes | Yes | Yes | 4 | ? | ? | ? |
draggable |
Yes | Yes | Yes | 4 | Yes | Yes | ? |
dropzone |
Yes | Yes | Yes | 4 | ? | ? | ? |
focus |
? | ? | Yes | 5 | ? | ? | ? |
forceSpellCheck
|
Yes | Yes | Yes | 4 | ? | ? | ? |
hidden |
Yes | Yes | Yes | 4 | ? | ? | ? |
inert |
60 | 60 | ? | ? | 47 | ? | ? |
isContentEditable |
Yes | Yes | Yes | 4 | ? | ? | ? |
itemId
|
Yes | Yes | Yes | 4 | ? | ? | ? |
itemProp
|
Yes | Yes | Yes | 4 | ? | ? | ? |
itemRef
|
Yes | Yes | Yes | 4 | ? | ? | ? |
itemScope
|
Yes | Yes | Yes | 4 | ? | ? | ? |
itemType
|
Yes | Yes | Yes | 4 | ? | ? | ? |
itemValue |
Yes | Yes | Yes | 4 | ? | ? | ? |
lang |
Yes | Yes | Yes | 4 | ? | ? | ? |
noModule |
60 | 60 | ? | ? | 47 | ? | ? |
nonce |
Yes | Yes | ? | ? | ? | ? | ? |
offsetHeight
|
Yes | Yes | Yes | 4 | ? | ? | ? |
offsetLeft
|
Yes | Yes | Yes | 4 | ? | ? | ? |
offsetParent
|
Yes | Yes | Yes | 4 | ? | ? | ? |
offsetTop
|
Yes | Yes | Yes | 4 | ? | ? | ? |
offsetWidth
|
Yes | Yes | Yes | 4 | ? | ? | ? |
onModule |
60 | 60 | ? | ? | 47 | ? | ? |
oncopy
|
? | ? | Yes | 4 | ? | ? | ? |
oncut
|
? | ? | Yes | 4 | ? | ? | ? |
onpaste
|
? | ? | Yes | 4 | ? | ? | ? |
outerText
|
Yes | Yes | Yes | No | Yes | Yes | ? |
spellcheck |
Yes | Yes | Yes | 4 | ? | ? | ? |
style |
Yes | Yes | Yes | 4 | ? | ? | ? |
tabIndex |
Yes | Yes | Yes | 4 | ? | ? | ? |
title |
Yes | Yes | Yes | 4 | ? | ? | ? |
translate
|
Yes | Yes | Yes | 4 | ? | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement