--- title: HTMLElement slug: Web/API/HTMLElement tags: - API - HTML DOM - Interface - NeedsMobileBrowserCompatibility - NeedsNewLayout - NeedsTranslation - Reference - TopicStub translation_of: Web/API/HTMLElement ---
The HTMLElement
interface represents any HTML element. Some elements directly implement this interface, others implement it via an interface that inherits it.
{{InheritanceDiagram}}
Inherits properties from its parent, {{domxref("Element")}}, and implements those from {{domxref("GlobalEventHandlers")}} and {{domxref("TouchEventHandlers")}}.
"true"
means the element is editable and a value of "false"
means it isn't.null
.data-*
) .dir
global attribute, representing the directionality of the element. Possible values are "ltr"
, "rtl"
, and "auto"
.dropzone
global attribute and describing the behavior of the element regarding a drop operation.double
containing the height of an element, relative to the layout.double
, the distance from this element's left border to its offsetParent
's left border.double
, the distance from this element's top border to its offsetParent
's top border.double
containing the width of an element, relative to the layout.long
representing the position of the element in the tabbing order.Most event handler properties, of the form onXYZ
, are defined on the {{domxref("GlobalEventHandlers")}} or {{domxref("TouchEventHandlers")}} interfaces and implemented by HTMLElement
. In addition, the following handlers are specific to HTMLElement
.
copy
event ({{bug("280959")}}).cut
event ({{bug("280959")}}).paste
event ({{bug("280959")}}).Inherits methods from its parent, {{domxref("Element")}}.
Specification | Status | Comment |
---|---|---|
{{SpecName('CSSOM View', '#extensions-to-the-htmlelement-interface', 'HTMLElement')}} | {{Spec2('CSSOM View')}} | Added the following properties: offsetParent , offsetTop , offsetLeft , offsetWidth , and offsetHeight . |
{{SpecName('HTML WHATWG', 'elements.html#htmlelement', 'HTMLElement')}} | {{Spec2('HTML WHATWG')}} | Added the following properties: translate , itemScope , itemType , itemId , itemRef , itemProp , properties , and itemValue .Added the following method: forceSpellcheck() .Moved the onXYZ attributes to the {{domxref("GlobalEventHandlers")}} interface and added an inheritance from it. |
{{SpecName('HTML5 W3C', 'dom.html#htmlelement', 'HTMLElement')}} | {{Spec2('HTML5 W3C')}} | 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 {{domxref("Element")}} interface. |
{{SpecName('DOM2 HTML', 'html.html#ID-011100101', 'HTMLElement')}} | {{Spec2('DOM2 HTML')}} | No change from {{SpecName('DOM2 HTML')}} |
{{SpecName('DOM1', 'level-one-html.html#ID-011100101', 'HTMLElement')}} | {{Spec2('DOM1')}} | Initial definition. |
{{CompatibilityTable}}
Feature | Firefox (Gecko) | Chrome | Edge | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Basic support | {{CompatGeckoDesktop("1.0")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.accessKey", "accessKey")}} | {{CompatGeckoDesktop("5.0")}} | {{CompatChrome(17)}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | 6.0 |
{{domxref("HTMLElement.accessKeyLabel", "accessKeyLabel")}} | {{CompatGeckoDesktop("8.0")}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}}{{WebkitBug(72715)}} |
{{domxref("HTMLElement.blur()", "blur()")}} | {{CompatGeckoDesktop("5.0")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | 9 | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.click()", "click()")}} | {{CompatGeckoDesktop("5.0")}} | {{CompatChrome(9)}} | {{CompatVersionUnknown}} | 9 | {{CompatUnknown}} | 6.0 |
{{domxref("HTMLElement.dataset", "dataset")}} | {{CompatGeckoDesktop("6.0")}} | {{CompatChrome(8)}} | {{CompatVersionUnknown}} | 11 | 11.10 | 5.1 |
{{domxref("HTMLElement.focus()", "focus()")}} | {{CompatGeckoDesktop("5.0")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | 9 | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.contentEditable", "contentEditable")}} | {{CompatGeckoDesktop("1.9")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | 5.5 | 9 | {{CompatVersionUnknown}} |
{{domxref("HTMLElement.spellcheck", "spellcheck")}} | {{CompatGeckoDesktop("1.8.1")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.style", "style")}} | {{CompatVersionUnknown}} (returns a {{domxref("CSS2Properties")}}, rather than a {{domxref("CSSStyleDeclaration")}}) | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
{{domxref("HTMLElement.forceSpellCheck", "forceSpellCheck()")}} {{experimental_inline}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
{{domxref("HTMLElement.draggable", "draggable")}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | 12.0 | {{CompatUnknown}} |
{{domxref("HTMLElement.dropzone", "dropzone")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | 12.0 | {{CompatNo}} |
{{domxref("HTMLElement.offsetLeft", "offsetLeft")}}, {{domxref("HTMLElement.offsetTop", "offsetTop")}}, {{domxref("HTMLElement.offsetParent", "offsetParent")}}, {{domxref("HTMLElement.offsetHeight", "offsetHeight")}} and {{domxref("HTMLElement.offsetWidth", "offsetWidth")}} {{experimental_inline}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.onModule")}} | {{CompatUnknown}} | {{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOpera(47)}} | {{CompatUnknown}} |
{{domxref("HTMLElement.translate", "translate")}} {{experimental_inline}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
{{domxref("HTMLElement.itemScope", "itemScope")}}, {{domxref("HTMLElement.itemType", "itemType")}}, {{domxref("HTMLElement.itemRef", "itemRef")}}, {{domxref("HTMLElement.itemId", "itemId")}}, {{domxref("HTMLElement.itemProp", "itemProp")}}, and {{domxref("HTMLElement.itemValue", "itemValue")}} {{experimental_inline}} | {{CompatGeckoDesktop("6.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | 11.60 (Removed in Opera 15) |
{{CompatNo}} |
{{domxref("HTMLElement.properties", "properties")}} {{experimental_inline}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.ontouchstart")}}, {{domxref("HTMLElement.ontouchend")}}, {{domxref("HTMLElement.ontouchmove")}}, {{domxref("HTMLElement.ontouchenter")}}, {{domxref("HTMLElement.ontouchleave")}}, and {{domxref("HTMLElement.ontouchcancel")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatNo}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatVersionUnknown}} |
{{domxref("HTMLElement.oncopy")}}, {{domxref("HTMLElement.oncut")}}, and {{domxref("HTMLElement.onpaste")}} {{Non-standard_inline}} | {{CompatGeckoDesktop("1.9")}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Feature | Firefox Mobile (Gecko) | Android Webview | Chrome for Android | Edge | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|---|
Basic support |
{{CompatGeckoMobile("1.0")}} |
{{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.accessKey", "accessKey")}} | {{CompatGeckoMobile("5.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.accessKeyLabel", "accessKeyLabel")}} | {{CompatGeckoMobile("8.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.blur()", "blur()")}} | {{CompatGeckoMobile("5.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.click()", "click()")}} | {{CompatGeckoMobile("5.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.dataset", "dataset")}} | {{CompatGeckoMobile("6.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.focus()", "focus()")}} | {{CompatGeckoMobile("5.0")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
{{domxref("HTMLElement.onModule", "onModule()")}} | {{CompatUnknown}} | {{CompatChrome(60)}} | {{CompatChrome(60)}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatOperaMobile(47)}} | {{CompatUnknown}} |
{{domxref("HTMLElement.oncopy")}}, {{domxref("HTMLElement.oncut")}}, and {{domxref("HTMLElement.onpaste")}} {{Non-standard_inline}} | {{CompatGeckoMobile("1.9")}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatVersionUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |