DekGenius.com
Team LiB   Previous Section   Next Section
HTMLElement the base interface for all HTML elements

Availability

DOM Level 1 HTML

Inherits from/Overrides

Node figs/U2192.gif Element figs/U2192.gif HTMLElement

Also Implements

ElementCSSInlineStyle

If the implementation supports CSS style sheets, all objects that implement this interface also implement the ElementCSSInlineStyle interface. Because CSS support is quite common in web browsers, the style property defined by that interface is included here for convenience.

Subinterfaces

HTMLAnchorElement
HTMLAppletElement
HTMLAreaElement
HTMLBRElement
HTMLBaseElement
HTMLBaseFontElement
HTMLBodyElement
HTMLButtonElement
HTMLDListElement
HTMLDirectoryElement
HTMLDivElement
HTMLFieldSetElement
HTMLFontElement
HTMLFormElement
HTMLFrameElement
HTMLFrameSetElement
HTMLHRElement
HTMLHeadElement
HTMLHeadingElement
HTMLHtmlElement
HTMLIFrameElement
HTMLImageElement
HTMLInputElement
HTMLIsIndexElement
HTMLLIElement
HTMLLabelElement
HTMLLegendElement
HTMLLinkElement
HTMLMapElement
HTMLMenuElement
HTMLMetaElement
HTMLModElement
HTMLOListElement
HTMLObjectElement
HTMLOptGroupElement
HTMLOptionElement
HTMLParagraphElement
HTMLParamElement
HTMLPreElement
HTMLQuoteElement
HTMLScriptElement
HTMLSelectElement
HTMLStyleElement
HTMLTableCaptionElement
HTMLTableCellElement
HTMLTableColElement
HTMLTableElement
HTMLTableRowElement
HTMLTableSectionElement
HTMLTextAreaElement
HTMLTitleElement
HTMLUListElement
   

Properties

readonly CSS2Properties style

The value of the style attribute that specifies inline CSS styles for this element. This property is not actually defined directly by the HTMLElement interface; instead, it is defined by the ElementCSSInlineStyle interface. If a browser supports CSS style sheets, all of its HTMLElement objects implement ElementCSSInlineStyle and define this style property. The value of this property is an object that implements the CSSStyleDeclaration interface and the (more commonly used) CSS2Properties interface.

String className

The value of the class attribute of the element, which specifies the name of a CSS class. Note that this property is not named "class" because that name is a reserved word in JavaScript.

String dir

The value of the dir attribute of the element, which specifies the text direction for the document.

String id

The value of the id attribute. No two elements within the same document should have the same value for id.

String lang

The value of the lang attribute, which specifies the language code for the document.

String title

The value of the title attribute, which specifies descriptive text suitable for display in a "tooltip" for the element.

Description

This interface defines properties that represent the attributes shared by all HTML elements. All HTML elements implement this interface, and most implement a tag-specific subinterface that defines properties for each of that tag's attributes. In addition to the properties listed here, see the HTMLElement reference page in the client-side reference section for a list of DOM Level 0 event handler properties that are supported by all HTML elements in a document.

Some HTML tags do not allow any attributes other than the universal attributes allowed on all HTML tags and represented by the properties of HTMLElement. These tags do not have their own tag-specific subinterface, and elements of this type in the document tree are represented by an HTMLElement object. The tags without a tag-specific interface of their own are the following:

<abbr>

<acronym>

<address>

<b>

<bdo>

<big>

<center>

<cite>

<code>

<dd>

<dfn>

<dt>

<em>

<i>

<kbd>

<noframes>

<noscript>

<s>

<samp>

<small>

<span>

<strike>

<strong>

<sub>

<sup>

<tt>

<u>

<var>

As you can see from the earlier "Subinterfaces" section, there are many HTML tags that do have tag-specific subinterfaces. Typically, a tag named T has a tag-specific interface named HTMLTElement. For example, the <head> tag is represented by the HTMLHeadElement interface. In a few cases, two or more related tags share a single interface, as in the case of the <h1> through <h6> tags, which are all represented by the HTMLHeadingElement interface.

Most of these tag-specific interfaces do nothing more than define a JavaScript property for each attribute of the HTML tag. The JavaScript properties have the same names as the attributes and use lowercase (e.g., id) or, when the attribute name consists of multiple words, mixed-case (e.g., className). When an HTML attribute name is a reserved word in Java or JavaScript, the property name is changed slightly. For example, the class attribute of all HTML tags becomes the className property of the HTMLElement interface because class is a reserved word. Similarly, the for attribute of <label> and <script> tags becomes the htmlFor property of the HTMLLabelElement and HTMLScriptElement interfaces because for is a reserved word. The meanings of those properties that correspond directly to HTML attributes are defined by the HTML specification, and documenting each one is beyond the scope of this book.

The following table lists all the HTML tags that have a corresponding subinterface of HTMLElement. For each tag, the table lists the interface name and the names of the properties and methods it defines. All properties are read/write strings unless otherwise specified. For properties that are not read/write strings, the property type is specified in square brackets before the property name. Because these interfaces and their properties map so directly to HTML elements and attributes, most interfaces do not have reference pages of their own in this book, and you should consult an HTML reference for details. The exceptions are interfaces that define methods and interfaces that represent certain particularly important tags, such as the <body> tag. These interfaces are marked with a * in the table, and you can look them up in this reference section for further details.

HTML tag

DOM interface, properties, and methods

all tags

HTMLElement*: id, title, lang, dir, className

<a>

HTMLAnchorElement*: accessKey, charset, coords, href, hreflang, name, rel, rev, shape, [long] tabIndex, target, type, blur( ), focus( )

<applet>

HTMLAppletElement**: align**, alt**, archive**, code**, codeBase**, height**, hspace**, name**, object**, vspace**, width**

<area>

HTMLAreaElement: accessKey, alt, coords, href, [boolean] noHref, shape, [long] tabIndex, target

<base>

HTMLBaseElement: href, target

<basefont>

HTMLBaseFontElement**: color**, face**, size**

<blockquote>, <q>

HTMLQuoteElement: cite

<body>

HTMLBodyElement*: aLink**, background**, bgColor**, link**, text**, vLink**

<br>

HTMLBRElement: clear**

<button>

HTMLButtonElement: [readonly HTMLFormElement] form, accessKey, [boolean] disabled, name, [long] tabIndex, [readonly] type, value

<caption>

HTMLTableCaptionElement*: align**

<col>, <colgroup>

HTMLTableColElement*: align, ch, chOff, [long] span, vAlign, width

<del>, <ins>

HTMLModElement: cite, dateTime

<dir>

HTMLDirectoryElement**: [boolean] compact**

<div>

HTMLDivElement: align**

<dl>

HTMLDListElement: [boolean] compact**

<fieldset>

HTMLFieldSetElement: [readonly HTMLFormElement] form

<font>

HTMLFontElement**: color**, face**, size**

<form>

HTMLFormElement*: [readonly HTMLCollection] elements, [readonly long] length, name, acceptCharset, action, enctype, method, target, submit( ), reset( )

<frame>

HTMLFrameElement: frameBorder, longDesc, marginHeight, marginWidth, name, [boolean] noResize, scrolling, src, [readonly Document] contentDocument***

<frameset>

HTMLFrameSetElement: cols, rows

<h1>, <h2>, <h3>, <h4>, <h5>, <h6>

HTMLHeadingElement: align**

<head>

HTMLHeadElement: profile

<hr>

HTMLHRElement: align**, [boolean] noShade**, size**, width**

<html>

HTMLHtmlElement: version**

<iframe>

HTMLIFrameElement: align**, frameBorder, height, longDesc, marginHeight, marginWidth, name, scrolling, src, width, [readonly Document] contentDocument***

<img>

HTMLImageElement: align**, alt, [long] border**, [long] height, [long] hspace**, [boolean] isMap, longDesc, name, src, useMap, [long] vspace**, [long] width

<input>

HTMLInputElement*: defaultValue, [boolean] defaultChecked, [readonly HTMLFormElement] form, accept, accessKey, align**, alt, [boolean] checked, [boolean] disabled, [long] maxLength, name, [boolean] readOnly, size, src, [long] tabIndex, type, useMap, value, blur( ), focus( ), select( ), click( )

<ins>

See <del>

<isindex>

HTMLIsIndexElement**: [readonly HTMLFormElement] form, prompt**

<label>

HTMLLabelElement: [readonly HTMLFormElement] form, accessKey, htmlFor

<legend>

HTMLLegendElement: [readonly HTMLFormElement] form, accessKey, align**

<li>

HTMLLIElement: type**, [long] value**

<link>

HTMLLinkElement: [boolean] disabled, charset, href, hreflang, media, rel, rev, target, type

<map>

HTMLMapElement: [readonly HTMLCollection of HTMLAreaElement] areas, name

<menu>

HTMLMenuElement**: [boolean] compact**

<meta>

HTMLMetaElement: content, httpEquiv, name, scheme

<object>

HTMLObjectElement: code, align**, archive, border**, codeBase, codeType, data, [boolean] declare, height, hspace**, name, standby, [long] tabIndex, type, useMap, vspace**, width, [readonly Document] contentDocument***

<ol>

HTMLOListElement: [boolean] compact**, [long] start**, type**

<optgroup>

HTMLOptGroupElement: [boolean] disabled, label

<option>

HTMLOptionElement*: [readonly HTMLFormElement] form, [boolean] defaultSelected, [readonly] text, [readonly long] index, [boolean] disabled, label, [boolean] selected, value

<p>

HTMLParagraphElement: align**

<param>

HTMLParamElement: name, type, value, valueType

<pre>

HTMLPreElement: [long] width**

<q>

See <blockquote>

<script>

HTMLScriptElement: text, htmlFor, event, charset, [boolean] defer, src, type

<select>

HTMLSelectElement*: [readonly] type, [long] selectedIndex, value, [readonly long] length, [readonly HTMLFormElement] form, [readonly HTMLCollection of HTMLOptionElement] options, [boolean] disabled, [boolean] multiple, name, [long] size, [long] tabIndex, add( ), remove( ), blur( ), focus( )

<style>

HTMLStyleElement: [boolean] disabled, media, type

<table>

HTMLTableElement*: [HTMLTableCaptionElement] caption, [HTMLTableSectionElement] tHead, [HTMLTableSectionElement] tFoot, [readonly HTMLCollection of HTMLTableRowElement] rows, [readonly HTMLCollection of HTMLTableSectionElement] tBodies, align**, bgColor**, border, cellPadding, cellSpacing, frame, rules, summary, width, createTHead( ), deleteTHead( ), createTFoot( ), deleteTFoot( ), createCaption( ), deleteCaption( ), insertRow( ), deleteRow( )

<tbody>, <tfoot>, <thead>

HTMLTableSectionElement*: align, ch, chOff, vAlign, [readonly HTMLCollection of HTMLTableRowElement] rows, insertRow( ), deleteRow( )

<td>, <th>

HTMLTableCellElement*: [readonly long] cellIndex, abbr, align, axis, bgColor**, ch, chOff, [long] colSpan, headers, height**, [boolean] noWrap**, [long] rowSpan, scope, vAlign, width**

<textarea>

HTMLTextAreaElement*: defaultValue, [readonly HTMLFormElement] form, accessKey, [long] cols, [boolean] disabled, name, [boolean] readOnly, [long] rows, [long] tabIndex, [readonly] type, value, blur( ), focus( ), select( )

<tfoot>

See <tbody>

<th>

See <td>

<thead>

See <tbody>

<title>

HTMLTitleElement: text

<tr>

HTMLTableRowElement*: [readonly long] rowIndex, [readonly long] sectionRowIndex, [readonly HTMLCollection of HTMLTableCellElement] cells, align, bgColor**, ch, chOff, vAlign, insertCell( ), deleteCell( )

<ul>

HTMLUListElement: [boolean] compact**, type**

* Indicates interfaces documented in this book.

** Indicates deprecated elements and attributes.

*** Indicates attributes added in HTML DOM Level 2 working draft.

See Also

HTMLElement in the client-side reference section

Type of

HTMLDocument.body

Passed to

HTMLSelectElement.add( )

Returned by

HTMLTableElement.createCaption( ), HTMLTableElement.createTFoot( ), HTMLTableElement.createTHead( ), HTMLTableElement.insertRow( ), HTMLTableRowElement.insertCell( ), HTMLTableSectionElement.insertRow( )

    Team LiB   Previous Section   Next Section