25.156. HTMLElement: an element in an HTML documentDOM Level 2 HTML: Node |
<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> |
Most HTML tags define properties other than those explicitly listed previously. The DOM Level 2 HTML specification defines tag-specific interfaces for these tags, so that all standard HTML attributes have a corresponding standard JavaScript property. 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., longDesc). When an HTML attribute name is a reserved word in Java or JavaScript, the property name is changed slightly. For example, 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 DOM 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. Quite a few tags and attributes are deprecated in HTML 4 and are marked with an * in this table.
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 represent tags that are particularly important to client-side JavaScript programmers, such as the <form> and <input> tags. Those tags are documented in this book, under names that do not include the "HTML" prefix or the "Element" suffix. See, for example, the entries for Anchor, Applet, Canvas, Form, Image, Input, Link, Option, Select, Table, and Textarea:
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[*] |
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, html For, event, charset, [boolean] defer, src, type |
<select> | HTMLSelectElement: [readonly] type, [long] selectedIndex, value, [readonlylong] 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 deprecated elements and attributes.
Anchor, Element, Form, HTMLDocument, Image, Input, Link, Node, Option, Select, Table, TableCell, TableRow, TableSection, Textarea; Chapter 15