--- title: HTMLElement slug: Web/API/HTMLElement tags: - API - HTML DOM - Interface translation_of: Web/API/HTMLElement ---
Interface HTMLElement đại diện cho mọi phần tử HTML. Một vài phần tử sử dụng trực tiếp interface này, một vài phần tử khác lại sử dụng nó thông qua các lớp khác kế thừa nó.
{{InheritanceDiagram}}
Được kế thừa từ {{domxref("Element")}}, và sử dụng chúng từ {{domxref("GlobalEventHandlers")}} và {{domxref("TouchEventHandlers")}}.
"true", ta có thể chỉnh sửa phần tử này và ngược lại nếu giá trị là "false".null.data-*) .dir, đại diện cho hướng hiển thị của phần tử. Các giá trị cho phép là "ltr", "rtl", và "auto".dropzone mô tả hành vi của phần tử liên quan đến hành động thả (drop).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")}}).Được kế thừa từ {{domxref("Element")}}.
Bắt các sự kiện bằng cách sự dụng phương thức addEventListener() hoặc bằng cách gán một thuộc tính sự sự kiện on_tên_sự_kiện dựa trên interface này.
invalidoninvalid.animationcancelonanimationcancel.animationendonanimationend.animationiterationonanimationiteration.animationstartonanimationstart.beforeinputinputoninput.gotpointercapturesetPointerCapture().ongotpointercapture property.lostpointercaptureonlostpointercapture property.pointercancelonpointercancel property.pointerdownonpointerdown property.pointerenteronpointerenter property.pointerleaveonpointerleave property.pointermoveonpointermove property.pointeroutonpointerout property.pointeroveronpointerover property.pointeruponpointerup property.transitioncancelontransitioncancel.transitionendontransitionend.transitionrunontransitionrun.transitionstartontransitionstart.| 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. |
{{Compat("api.HTMLElement")}}