The DOM HTML API
The core API works with any valid XML, including XHTML; the HTML API is specific to valid XHTML and HTML only. It consists of a set of HTML objects, each associated with a valid HTML element tag; all have properties and methods appropriate to the object.
Though a separate set of objects, the two models—core and HTML—overlap, with the HTML API
objects incorporating methods and properties from both models. As such,
HTML API objects inherit properties and methods of a basic HTML Element, as well as the core Node object (discussed in the next
section).
The HTML Objects and Their Properties
The HTML API is a set of interfaces rather than actual classes. These interfaces can access existing or newly created page objects, and each is associated with a specific type of page object.
Tip
I’ve introduced a new term, interface. For our purposes, an interface is an object representing the specific page element. It differs from a class in that there is no constructor; objects are created through other functions rather than directly.
Most HTML interface objects inherit the properties and
methods of the Element and Node objects—both of which are part of the
core model, and discussed later in the chapter. Most also inherit from
HTMLElement, which has the
following properties (based on the set of attributes of the same name
allowed for all HTML elements): id,
title, lang, dir, and className.
Each interface object takes its name from the HTML formal element name, not necessarily the element ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access