aboutsummaryrefslogtreecommitdiff
path: root/files/uk/web/api/html_dom_api/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/uk/web/api/html_dom_api/index.html')
-rw-r--r--files/uk/web/api/html_dom_api/index.html472
1 files changed, 472 insertions, 0 deletions
diff --git a/files/uk/web/api/html_dom_api/index.html b/files/uk/web/api/html_dom_api/index.html
new file mode 100644
index 0000000000..4f94294e96
--- /dev/null
+++ b/files/uk/web/api/html_dom_api/index.html
@@ -0,0 +1,472 @@
+---
+title: The HTML DOM API
+slug: Web/API/HTML_DOM_API
+tags:
+ - API
+ - Beginner
+ - DOM
+ - Documents
+ - Elements
+ - HTML DOM
+ - HTML DOM API
+ - NeedsTranslation
+ - Nodes
+ - Overview
+ - TopicStub
+ - Web
+ - Windows
+ - hierarchy
+translation_of: Web/API/HTML_DOM_API
+---
+<p>{{DefaultAPISidebar("HTML DOM")}}</p>
+
+<p>The <strong>HTML DOM API</strong> is made up of the interfaces that define the functionality of each of the {{Glossary("element", "elements")}} in {{Glossary("HTML")}}, as well as any supporting types and interfaces they rely upon.</p>
+
+<p>The functional areas included in the HTML DOM API include:</p>
+
+<ul>
+ <li>Access to and control of HTML elements via the {{Glossary("DOM")}}.</li>
+ <li>Access to and manipulation of form data.</li>
+ <li>Interacting with the contents of 2D images and the context of an HTML {{HTMLElement("canvas")}}, for example to draw on top of them.</li>
+ <li>Management of media connected to the HTML media elements ({{HTMLElement("audio")}} and {{HTMLElement("video")}}).</li>
+ <li>Dragging and dropping of content on webpages.</li>
+ <li>Access to the browser navigation history</li>
+ <li>Supporting and connective interfaces for other APIs such as <a href="/en-US/docs/Web/Web_Components">Web Components</a>, <a href="/en-US/docs/Web/API/Web_Storage_API">Web Storage</a>, <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a>, <a href="/en-US/docs/Web/API/WebSockets_API">WebSocket</a>, and <a href="/en-US/docs/Web/API/Server-sent_events">Server-sent events</a>.</li>
+</ul>
+
+<h2 id="HTML_DOM_concepts_and_usage">HTML DOM concepts and usage</h2>
+
+<p>In this article, we'll focus on the parts of the HTML DOM that involve engaging with HTML elements. Discussion of other areas, such as <a href="/en-US/docs/Web/API/HTML_Drag_and_Drop_API">Drag and Drop</a>, <a href="/en-US/docs/Web/API/WebSockets_API">WebSockets</a>, <a href="/en-US/docs/Web/API/Web_Storage_API">Web Storage</a>, etc. can be found in the documentation for those APIs.</p>
+
+<h3 id="Structure_of_an_HTML_document">Structure of an HTML document</h3>
+
+<p>The Document Object Model ({{Glossary("DOM")}}) is an architecture that describes the structure of a {{domxref("document")}}; each document is represented by an instance of the interface {{domxref("Document")}}. A document, in turn, consists of a hierarchical tree of <strong>nodes</strong>, in which a node is a fundamental record representing a single object within the document (such as an element or text node).</p>
+
+<p>Nodes may be strictly organizational, providing a means for grouping other nodes together or for providing a point at which a hierarchy can be constructed; other nodes may represent visible components of a document. Each node is based on the {{domxref("Node")}} interface, which provides properties for getting information about the node as well as methods for creating, deleting, and organizing nodes within the DOM.</p>
+
+<p>Nodes don't have any concept of including the content that is actually displayed in the document. They're empty vessels. The fundamental notion of a node that can represent visual content is introduced by the {{domxref("Element")}} interface. An <code>Element</code> object instance represents a single element in a document created using either HTML or an {{glossary("XML")}} vocabulary such as {{glossary("SVG")}}.</p>
+
+<p>For example, consider a document with two elements, one of which has two more elements nested inside it:</p>
+
+<p><img alt="Structure of a document with elements inside a document in a window" src="https://mdn.mozillademos.org/files/16587/dom-structure.svg" style="display: block; height: 379px; margin: 0 auto; width: 291px;"></p>
+
+<p>While the {{domxref("Document")}} interface is defined as part of the <a href="/en-US/docs/Web/API/Document_Object_Model">DOM</a> specification, the HTML specification significantly enhances it to add information specific to using the DOM in the context of a web browser, as well as to using it to represent HTML documents specifically.</p>
+
+<p>Among the things added to <code>Document</code> by the HTML standard are:</p>
+
+<ul>
+ <li>Support for accessing various information provided by the {{Glossary("HTTP")}} headers when loading the page, such as the <a href="/en-US/docs/Web/API/Document/location">location</a> from which the document was loaded, <a href="/en-US/docs/Web/API/Document/cookie">cookies</a>, <a href="/en-US/docs/Web/API/Document/lastModified">modification date</a>, <a href="/en-US/docs/Web/API/Document/referrer">referring site</a>, and so forth.</li>
+ <li>Access to lists of elements in the document's {{HTMLElement("head")}} block and <a href="/en-US/docs/Web/API/Document/body">body</a>, as well as lists of the <a href="/en-US/docs/Web/API/Document/images">images</a>, <a href="/en-US/docs/Web/API/Document/links">links</a>, <a href="/en-US/docs/Web/API/Document/scripts">scripts</a>, etc. contained in the document.</li>
+ <li>Support for interacting with the user by examining <a href="/en-US/docs/Web/API/Document/hasFocus">focus</a> and by executing commands on <a href="/en-US/docs/Web/HTML/Global_attributes/contenteditable">editable content</a>.</li>
+ <li>Event handlers for document <a href="/en-US/docs/Web/API/GlobalEventHandlers">events defined by the HTML standard</a> to allow access to <a href="/en-US/docs/Web/API/MouseEvent">mouse</a> and <a href="/en-US/docs/Web/API/KeyboardEvent">keyboard</a> events, <a href="/en-US/docs/Web/API/HTML_Drag_and_Drop_API">drag and drop</a>, <a href="/en-US/docs/Web/API/HTMLMediaElement">media control</a>, and more.</li>
+ <li>Event handlers for events that can be delivered to both elements and documents; these presently include only <a href="/en-US/docs/Web/API/HTMLElement/oncopy">copy</a>, <a href="/en-US/docs/Web/API/HTMLElement/oncut">cut</a>, and <a href="/en-US/docs/Web/API/HTMLElement/onpaste">paste</a> actions.</li>
+</ul>
+
+<h3 id="HTML_element_interfaces">HTML element interfaces</h3>
+
+<p>The <code>Element</code> interface has been further adapted to represent HTML elements specifically by introducing the {{domxref("HTMLElement")}} interface, which all more specific HTML element classes inherit from. This expands the <code>Element</code> class to add HTML-specific general features to the element nodes. Properties added by <code>HTMLElement</code> include for example {{domxref("HTMLElement.hidden", "hidden")}} and {{domxref("HTMLElement.innerText", "innerText")}}. <code>HTMLElement</code> also adds all the <a href="/en-US/docs/Web/API/GlobalEventHandlers">global event handlers</a>.</p>
+
+<p>An {{Glossary("HTML")}} document is a DOM tree in which each of the nodes is an HTML element, represented by the {{domxref("HTMLElement")}} interface. The <code>HTMLElement</code> class, in turn, implements <code>Node</code>, so every element is also a node (but not the other way around). This way, the structural features implemented by the {{domxref("Node")}} interface are also available to HTML elements, allowing them to be nested within each other, created and deleted, moved around, and so forth.</p>
+
+<p>The <code>HTMLElement</code> interface is generic, however, providing only the functionality common to all HTML elements such as the element's ID, its coordinates, the HTML making up the element, information about scroll position, and so forth.</p>
+
+<p>In order to expand upon the functionality of the core <code>HTMLElement</code> interface to provide the features needed by a specific element, the <code>HTMLElement</code> class is subclassed to add the needed properties and methods. For example, the {{HTMLElement("canvas")}} element is represented by an object of type {{domxref("HTMLCanvasElement")}}. <code>HTMLCanvasElement</code> augments the <code>HTMLElement</code> type by adding properties such as {{domxref("HTMLCanvasElement.height", "height")}} and methods like {{domxref("HTMLCanvasElement.getContext", "getContext()")}} to provide canvas-specific features.</p>
+
+<p>The overall inheritance for HTML element classes looks like this:</p>
+
+<p><img alt="Hierarchy of interfaces for HTML elements" src="https://mdn.mozillademos.org/files/16596/html-dom-hierarchy.svg" style="display: block; height: 565px; margin: 0 auto; width: 661px;"></p>
+
+<p>As such, an element inherits the properties and methods of all of its ancestors. For example, consider a {{HTMLElement("a")}} element, which is represented in the DOM by an object of type {{domxref("HTMLAnchorElement")}}. The element, then, includes the anchor-specific properties and methods described in that class's documentation, but also those defined by {{domxref("HTMLElement")}} and {{domxref("Element")}}, as well as from {{domxref("Node")}} and, finally, {{domxref("EventTarget")}}.</p>
+
+<p>Each level defines a key aspect of the utility of the element. From <code>Node</code>, the element inherits concepts surrounding the ability for the element to be contained by another element, and to contain other elements itself. Of special importance is what is gained by inheriting from <code>EventTarget</code>: the ability to receive and handle events such as mouse clicks, play and pause events, and so forth.</p>
+
+<p>There are elements that share commonalities and thus have an additional intermediary type. For example, the {{HTMLElement("audio")}} and {{HTMLElement("video")}} elements both present audiovisual media. The corresponding types, {{domxref("HTMLAudioElement")}} and {{domxref("HTMLVideoElement")}}, are both based upon the common type {{domxref("HTMLMediaElement")}}, which in turn is based upon {{domxref("HTMLElement")}} and so forth. <code>HTMLMediaElement</code> defines the methods and properties held in common between audio and video elements.</p>
+
+<p>These element-specific interfaces make up the majority of the HTML DOM API, and are the focus of this article. To learn more about the actual structure of the <a href="/en-US/docs/Web/API/Document_Object_Model">DOM</a>, see <a href="/en-US/docs/Web/API/Document_Object_Model/Introduction">Introduction to the DOM</a>.</p>
+
+<h2 id="HTML_DOM_target_audience">HTML DOM target audience</h2>
+
+<p>The features exposed by the HTML DOM are among the most commonly-used APIs in the web developer's arsenal. All but the most simple web applications will use some features of the HTML DOM.</p>
+
+<h2 id="HTML_DOM_API_interfaces">HTML DOM API interfaces</h2>
+
+<p>The majority of the interfaces that comprise the HTML DOM API map almost one-to-one to individual HTML elements, or to a small group of elements with similar functionality. In addition, the HTML DOM API includes a few interfaces and types to support the HTML element interfaces.</p>
+
+<h3 id="HTML_element_interfaces_2">HTML element interfaces</h3>
+
+<p>These interfaces represent specific HTML elements (or sets of related elements which have the same properties and methods associated with them).</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLAnchorElement"><code>HTMLAnchorElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLAreaElement"><code>HTMLAreaElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLAudioElement"><code>HTMLAudioElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLBRElement"><code>HTMLBRElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLBaseElement"><code>HTMLBaseElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLBaseFontElement"><code>HTMLBaseFontElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLBodyElement"><code>HTMLBodyElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLButtonElement"><code>HTMLButtonElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLCanvasElement"><code>HTMLCanvasElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDListElement"><code>HTMLDListElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDataElement"><code>HTMLDataElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDataListElement"><code>HTMLDataListElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDetailsElement"><code>HTMLDetailsElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDialogElement"><code>HTMLDialogElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDirectoryElement"><code>HTMLDirectoryElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLDivElement"><code>HTMLDivElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLElement"><code>HTMLElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLEmbedElement"><code>HTMLEmbedElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFieldSetElement"><code>HTMLFieldSetElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFontElement"><code>HTMLFontElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFormElement"><code>HTMLFormElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFrameElement"><code>HTMLFrameElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFrameSetElement"><code>HTMLFrameSetElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLHRElement"><code>HTMLHRElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLHeadElement"><code>HTMLHeadElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLHeadingElement"><code>HTMLHeadingElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLHtmlElement"><code>HTMLHtmlElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLIFrameElement"><code>HTMLIFrameElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLImageElement"><code>HTMLImageElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLInputElement"><code>HTMLInputElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLIsIndexElement"><code>HTMLIsIndexElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLLIElement"><code>HTMLLIElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLLabelElement"><code>HTMLLabelElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLLegendElement"><code>HTMLLegendElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLLinkElement"><code>HTMLLinkElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMapElement"><code>HTMLMapElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMarqueeElement"><code>HTMLMarqueeElement</code></a> {{deprecated_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMediaElement"><code>HTMLMediaElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMenuElement"><code>HTMLMenuElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMenuItemElement"><code>HTMLMenuItemElement</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMetaElement"><code>HTMLMetaElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLMeterElement"><code>HTMLMeterElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLModElement"><code>HTMLModElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLOListElement"><code>HTMLOListElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLObjectElement"><code>HTMLObjectElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLOptGroupElement"><code>HTMLOptGroupElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLOptionElement"><code>HTMLOptionElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLOutputElement"><code>HTMLOutputElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLParagraphElement"><code>HTMLParagraphElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLParamElement"><code>HTMLParamElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLPictureElement"><code>HTMLPictureElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLPreElement"><code>HTMLPreElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLProgressElement"><code>HTMLProgressElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLQuoteElement"><code>HTMLQuoteElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLScriptElement"><code>HTMLScriptElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLSelectElement"><code>HTMLSelectElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLSlotElement"><code>HTMLSlotElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLSourceElement"><code>HTMLSourceElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLSpanElement"><code>HTMLSpanElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLStyleElement"><code>HTMLStyleElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableCaptionElement"><code>HTMLTableCaptionElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableCellElement"><code>HTMLTableCellElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableColElement"><code>HTMLTableColElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableElement"><code>HTMLTableElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableRowElement"><code>HTMLTableRowElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTableSectionElement"><code>HTMLTableSectionElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTemplateElement"><code>HTMLTemplateElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTextAreaElement"><code>HTMLTextAreaElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTimeElement"><code>HTMLTimeElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTitleElement"><code>HTMLTitleElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLTrackElement"><code>HTMLTrackElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLUListElement"><code>HTMLUListElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLUnknownElement"><code>HTMLUnknownElement</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLVideoElement"><code>HTMLVideoElement</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Web_app_and_browser_integration_interfaces">Web app and browser integration interfaces</h3>
+
+<p>These interfaces offer access to the browser window and document that contain the HTML, as well as to the browser's state, available plugins (if any), and various configuration options.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ApplicationCache"><code>ApplicationCache</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/BarProp"><code>BarProp</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/External"><code>External</code></a> {{deprecated_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Navigator"><code>Navigator</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Plugin"><code>Plugin</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/PluginArray"><code>PluginArray</code></a> {{obsolete_inline}}</span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><code><a href="/en-US/docs/Web/API/Window">Window</a></code></span></span></li>
+</ul>
+</div>
+
+<h3 id="Form_support_interfaces">Form support interfaces</h3>
+
+<p>These interfaces provide structure and functionality required by the elements used to create and manage forms, including the {{HTMLElement("form")}} and {{HTMLElement("input")}} elements.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/FormDataEvent"><code>FormDataEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLFormControlsCollection"><code>HTMLFormControlsCollection</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLOptionsCollection"><code>HTMLOptionsCollection</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/RadioNodeList"><code>RadioNodeList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ValidityState"><code>ValidityState</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Canvas_and_image_interfaces">Canvas and image interfaces</h3>
+
+<p>These interfaces represent objects used by the Canvas API as well as the {{HTMLElement("img")}} element and {{HTMLElement("picture")}} elements.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/CanvasGradient"><code>CanvasGradient</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/CanvasPattern"><code>CanvasPattern</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/CanvasRenderingContext2D"><code>CanvasRenderingContext2D</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ImageBitmap"><code>ImageBitmap</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ImageBitmapRenderingContext"><code>ImageBitmapRenderingContext</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ImageData"><code>ImageData</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/OffscreenCanvas"><code>OffscreenCanvas</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/OffscreenCanvasRenderingContext2D"><code>OffscreenCanvasRenderingContext2D</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Path2D"><code>Path2D</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TextMetrics"><code>TextMetrics</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Media_interfaces">Media interfaces</h3>
+
+<p>The media interfaces provide HTML access to the contents of the media elements: {{HTMLElement("audio")}} and {{HTMLElement("video")}}.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/AudioTrack"><code>AudioTrack</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/AudioTrackList"><code>AudioTrackList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MediaError"><code>MediaError</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TextTrack"><code>TextTrack</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TextTrackCue"><code>TextTrackCue</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TextTrackCueList"><code>TextTrackCueList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TextTrackList"><code>TextTrackList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TimeRanges"><code>TimeRanges</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/TrackEvent"><code>TrackEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/VideoTrack"><code>VideoTrack</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/VideoTrackList"><code>VideoTrackList</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Drag_and_drop_interfaces">Drag and drop interfaces</h3>
+
+<p>These interfaces are used by the <a href="/en-US/docs/Web/API/HTML_Drag_and_Drop_API">HTML Drag and Drop API</a> to represent individual draggable (or dragged) items, groups of dragged or draggable items, and to handle the drag and drop process.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DataTransfer"><code>DataTransfer</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DataTransferItem"><code>DataTransferItem</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DataTransferItemList"><code>DataTransferItemList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DragEvent"><code>DragEvent</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Page_history_interfaces">Page history interfaces</h3>
+
+<p>The History API interfaces let you access information about the browser's history, as well as to shift the browser's current tab forward and backward through that history.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/BeforeUnloadEvent"><code>BeforeUnloadEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HashChangeEvent"><code>HashChangeEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/History"><code>History</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Location"><code>Location</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/PageTransitionEvent"><code>PageTransitionEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/PopStateEvent"><code>PopStateEvent</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Web_Components_interfaces">Web Components interfaces</h3>
+
+<p>These interfaces are used by the <a href="/en-US/docs/Web/Web_Components">Web Components API</a> to create and manage the available <a href="/en-US/docs/Web/Web_Components/Using_custom_elements">custom elements</a>.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/CustomElementRegistry"><code>CustomElementRegistry</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Miscellaneous_and_supporting_interfaces">Miscellaneous and supporting interfaces</h3>
+
+<p>These supporting object types are used in a variety of ways in the HTML DOM API; in addition, {{domxref("PromiseRejectionEvent")}} represents the event delivered when a {{Glossary("JavaScript")}} {{jsxref("Promise")}} is rejected.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DOMStringList"><code>DOMStringList</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DOMStringMap"><code>DOMStringMap</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/ErrorEvent"><code>ErrorEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/HTMLAllCollection"><code>HTMLAllCollection</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MimeType"><code>MimeType</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MimeTypeArray"><code>MimeTypeArray</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/PromiseRejectionEvent"><code>PromiseRejectionEvent</code></a></span></span></li>
+</ul>
+</div>
+
+<h3 id="Interfaces_belonging_to_other_APIs">Interfaces belonging to other APIs</h3>
+
+<p>There are several interfaces which are technically defined in the HTML specification while actually being part of other APIs.</p>
+
+<h4 id="Web_storage_interfaces">Web storage interfaces</h4>
+
+<p>The <a href="/en-US/docs/Web/API/Web_Storage_API">Web Storage API</a> provides the ability for web sites to store data either temporarily or permanently on the user's device for later re-use.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Storage"><code>Storage</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/StorageEvent"><code>StorageEvent</code></a></span></span></li>
+</ul>
+</div>
+
+<h4 id="Web_Workers_interfaces">Web Workers interfaces</h4>
+
+<p>These interfaces are used by the <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers API</a> both to establish the ability for workers to interact with an app and its content, but also to support messaging between windows or apps.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/BroadcastChannel"><code>BroadcastChannel</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/DedicatedWorkerGlobalScope"><code>DedicatedWorkerGlobalScope</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MessageChannel"><code>MessageChannel</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MessageEvent"><code>MessageEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/MessagePort"><code>MessagePort</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/SharedWorker"><code>SharedWorker</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/SharedWorkerGlobalScope"><code>SharedWorkerGlobalScope</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/Worker"><code>Worker</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/WorkerGlobalScope"><code>WorkerGlobalScope</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/WorkerLocation"><code>WorkerLocation</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/WorkerNavigator "><code>WorkerNavigator </code></a></span></span></li>
+</ul>
+</div>
+
+<h4 id="WebSocket_interfaces">WebSocket interfaces</h4>
+
+<p>These interfaces, defined by the HTML specification, are used by the <a href="/en-US/docs/Web/API/WebSockets_API">WebSocket API</a>.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/CloseEvent"><code>CloseEvent</code></a></span></span></li>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/WebSocket"><code>WebSocket</code></a></span></span></li>
+</ul>
+</div>
+
+<h4 id="Server-sent_events_interfaces">Server-sent events interfaces</h4>
+
+<p>The {{domxref("EventSource")}} interface represents the source which sent or is sending <a href="/en-US/docs/Web/API/Server-sent_events">server-sent events</a>.</p>
+
+<div class="index">
+<ul>
+ <li><span class="indexListRow"><span class="indexListTerm"><a href="/en-US/docs/Web/API/EventSource"><code>EventSource</code></a></span></span></li>
+</ul>
+</div>
+
+<h2 id="Examples">Examples</h2>
+
+<p>In this example, an {{HTMLElement("input")}} element's {{domxref("HTMLInputElement.input_event", "input")}} event is monitored in order to update the state of a form's "submit" button based on whether or not a given field currently has a value.</p>
+
+<h4 id="JavaScript">JavaScript</h4>
+
+<pre class="brush: js">const nameField = document.getElementById("userName");
+const sendButton = document.getElementById("sendButton")
+
+sendButton.disabled = true;
+// [note: this is disabled since it causes this article to always load with this example focused and scrolled into view]
+//nameField.focus();
+
+nameField.addEventListener("input", event =&gt; {
+ const elem = event.target;
+ const valid = elem.value.length != 0;
+
+ if (valid &amp;&amp; sendButton.disabled) {
+ sendButton.disabled = false;
+ } else if (!valid &amp;&amp; !sendButton.disabled) {
+ sendButton.disabled = true;
+ }
+});</pre>
+
+<p>This code uses the {{domxref("Document")}} interface's {{domxref("Document.getElementById", "getElementById()")}} method to get the DOM object representing the {{HTMLElement("input")}} elements whose IDs are <code>userName</code> and <code>sendButton</code>.  With these, we can access the properties and methods that provide information about and grant control over these elements.</p>
+
+<p>The {{domxref("HTMLInputElement")}} object for the "Send" button's {{domxref("HTMLInputElement.disabled", "disabled")}} property is set to <code>true</code>, which disables the "Send" button so it can't be clicked. In addition, the user name input field is made the active focus by calling the {{domxref("HTMLElement.focus", "focus()")}} method it inherits from {{domxref("HTMLElement")}}.</p>
+
+<p>Then {{domxref("EventTarget.addEventListener", "addEventListener()")}} is called to add a handler for the <code>input</code> event to the user name input. This code looks at the length of the current value of the input; if it's zero, then the "Send" button is disabled if it's not already disabled. Otherwise, the code ensures that the button is enabled.</p>
+
+<p>With this in place, the "Send" button is always enabled whenever the user name input field has a value, and disabled when it's empty.</p>
+
+<h4 id="HTML">HTML</h4>
+
+<p>The HTML for the form looks like this:</p>
+
+<pre class="brush: html">&lt;p&gt;Please provide the information below. Items marked with "*" are required.&lt;/p&gt;
+&lt;form action="" method="get"&gt;
+  &lt;p&gt;
+    &lt;label for="userName" required&gt;Your name:&lt;/label&gt;
+    &lt;input type="text" id="userName"&gt; (*)
+  &lt;/p&gt;
+  &lt;p&gt;
+    &lt;label for="email"&gt;Email:&lt;/label&gt;
+    &lt;input type="email" id="userEmail"&gt;
+  &lt;/p&gt;
+  &lt;input type="submit" value="Send" id="sendButton"&gt;
+&lt;/form&gt;
+</pre>
+
+<h4 id="Result">Result</h4>
+
+<p>{{EmbedLiveSample("Examples", 640, 300)}}</p>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td>WHATWG HTML Specification</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('HTML5 W3C')}}</td>
+ <td>{{Spec2('HTML5 W3C')}}</td>
+ <td>No change from {{SpecName("DOM2 HTML")}}</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM2 HTML')}}</td>
+ <td>{{Spec2('DOM2 HTML')}}</td>
+ <td>No change from {{SpecName("DOM1")}}.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('DOM1')}}</td>
+ <td>{{Spec2('DOM1')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+
+
+<p>{{Compat("api.HTMLElement")}}</p>
+</div>
+
+<h2 id="See_also">See also</h2>
+
+<dl>
+ <dt>References</dt>
+ <dd>
+ <ul>
+ <li><a href="/en-US/docs/Web/HTML/Element">HTML elements reference</a></li>
+ <li><a href="/en-US/docs/Web/HTML/Attributes">HTML attribute reference</a></li>
+ <li><a href="/en-US/docs/Web/API/Document_Object_Model">Document Object Model (DOM)</a> reference</li>
+ </ul>
+ </dd>
+ <dt>Guides</dt>
+ <dd>
+ <ul>
+ <li>
+ <p><a href="/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Manipulating_documents" style="font-size: 1rem; letter-spacing: -0.00278rem;">Manipulating documents</a><span style="font-size: 1rem; letter-spacing: -0.00278rem;">: A beginner's guide to manipulating the DOM.</span></p>
+ </li>
+ </ul>
+ </dd>
+</dl>