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.accessKey
DOMString
representing the access key assigned to the element.HTMLElement.accessKeyLabel
Read only
DOMString
containing the element's assigned access key.HTMLElement.contentEditable
DOMString
, 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.dir
DOMString
, reflecting the dir
global attribute, representing the directionality of the element. Possible values are "ltr"
, "rtl"
, and "auto"
.HTMLElement.draggable
Boolean
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.hidden
Boolean
indicating if the element is hidden or not.HTMLElement.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.lang
DOMString
representing the language of an element's attributes, text, and element contents.HTMLElement.noModule
Boolean
indicating wether an import script can be executed in user agents that support module scripts.HTMLElement.offsetHeight
Read only
double
containing the height of an element, relative to the layout.HTMLElement.offsetLeft
Read only
double
, the distance from this element's left border to its offsetParent
's left border.HTMLElement.offsetParent
Read only
Element
that is the element from which all offset calculations are currently computed.HTMLElement.offsetTop
Read only
double
, the distance from this element's top border to its offsetParent
's top border.HTMLElement.offsetWidth
Read only
double
containing the width of an element, relative to the layout.HTMLElement.properties
Read only
HTMLPropertiesCollection
…HTMLElement.spellcheck
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
CSSStyleDeclaration
, an object representing the declarations of an element's style attributes.HTMLElement.tabIndex
long
representing the position of the element in the tabbing order.HTMLElement.title
DOMString
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. |
Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | 1.0 (1.7 or earlier) | ? | (Yes) | ? | ? | ? |
accessKey | 5.0 (5.0) | 17 | (Yes) | ? | ? | 6.0 |
accessKeyLabel | 8.0 (8.0) | ? | No support | ? | ? | No supportWebKit bug 72715 |
blur() | 5.0 (5.0) | ? | (Yes) | 9 | ? | ? |
click() | 5.0 (5.0) | 9 | (Yes) | 9 | ? | 6.0 |
dataset | 6.0 (6.0) | 8 | (Yes) | 11 | 11.10 | 5.1 |
focus() | 5.0 (5.0) | ? | (Yes) | 9 | ? | ? |
contentEditable | 3.0 (1.9) | (Yes) | (Yes) | 5.5 | 9 | (Yes) |
spellcheck | 2.0 (1.8.1) | ? | (Yes) | ? | ? | ? |
style |
(Yes) (returns a CSS2Properties , rather than a CSSStyleDeclaration ) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
forceSpellCheck()
| No support | No support | No support | No support | No support | No support |
draggable | (Yes) | ? | (Yes) | ? | 12.0 | ? |
dropzone | No support | No support | No support | No support | 12.0 | No support |
offsetLeft , offsetTop , offsetParent , offsetHeight and offsetWidth
| (Yes) | ? | (Yes) | (Yes) | ? | ? |
HTMLElement.onModule | ? | 60 | ? | ? | 47 | ? |
translate
| No support | No support | No support | No support | No support | No support |
itemScope , itemType , itemRef , itemId , itemProp , and itemValue
| 6.0 (6.0) | No support | No support | No support | 11.60 (Removed in Opera 15) | No support |
properties
| (Yes) | ? | No support | ? | ? | ? |
HTMLElement.ontouchstart , HTMLElement.ontouchend , HTMLElement.ontouchmove , HTMLElement.ontouchenter , HTMLElement.ontouchleave , and HTMLElement.ontouchcancel
| (Yes) | (Yes) | No support | No support | ? | (Yes) |
HTMLElement.oncopy , HTMLElement.oncut , and HTMLElement.onpaste
| 3.0 (1.9) | ? | (Yes) | ? | ? | ? |
Feature | Firefox Mobile (Gecko) | Android Webview | Chrome for Android | Edge | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support | 1.0 (1.0) | (Yes) | (Yes) | (Yes) | ? | ? | ? |
accessKey | 5.0 (5.0) | ? | ? | (Yes) | ? | ? | ? |
accessKeyLabel | 8.0 (8.0) | ? | ? | No support | ? | ? | ? |
blur() | 5.0 (5.0) | ? | ? | (Yes) | ? | ? | ? |
click() | 5.0 (5.0) | ? | ? | (Yes) | ? | ? | ? |
dataset | 6.0 (6.0) | ? | ? | (Yes) | ? | ? | ? |
focus() | 5.0 (5.0) | ? | ? | (Yes) | ? | ? | ? |
onModule() | ? | 60 | 60 | ? | ? | 47 | ? |
HTMLElement.oncopy , HTMLElement.oncut , and HTMLElement.onpaste
| 1.0 (1.9) | ? | ? | (Yes) | ? | ? | ? |
© 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