<LEGEND...>

Note : The <LEGEND> element is a new element introduced in HTML 4.0 draft specifications and is only supported by Internet Explorer 4.0 and above.

The <LEGEND> element provides a label for the <FIELDSET> element. For the <LEGEND> element to be used as the <FIELDSET> label, it must be the first element contained in the <FIELDSET> block.

<LEGEND> accepts the following attributes :

ALIGN="Alignment"
The ALIGN attribute specifies where the <LEGEND> text is located on the <FIELDSET> border. It can accept vales of bottom, center, left, right and top.

CLASS="Style Sheet class name"
The CLASS attribute is used to specify the <LEGEND> element as using a particular style sheet class. See the Style Sheets topic for details.

ID="Unique element identifier"
The ID attribute can be used to either reference a unique style sheet identifier, or to provide a unique name for the <LEGEND> element for scripting purposes. Any <LEGEND> element with an ID attribute can be directly manipulated in script by referencing its ID attribute, rather than working through the All collection to determine the element. See the Scripting introduction topic for more information.

LANG="language setting"
The LANG attribute can be used to specify what language the <LEGEND> element is using. It accepts any valid ISO standard language abbreviation (for example "en" for English, "de" for German etc.) For more details, see the Document Localisation section for more details.

LANGUAGE="Scripting language"
The LANGUAGE attribute can be used to expressly specify which scripting language Internet Explorer 4.0 uses to interpret any scripting information used in the <LEGEND> element. It can accept values of vbscript, vbs, javascript or jscript. The first two specify the scripting language as Visual Basic Script, the latter two specify it as using Javascript (the default scripting language used if no LANGUAGE attribute is set.

STYLE="In line style setting"
As well as using previously defined style sheet settings, the <LEGEND> element can have in-line stylings attached to it. See the Style Sheets topic for details.

TITLE="informational ToolTip"
The Internet Explorer 4.0 (and above) specific TITLE attribute is used for informational purposes. If present, the value of the TITLE attribute is presented as a ToolTip when the users mouse hovers over the <LEGEND> section.

Examples For an example of the <LEGEND> element, see the <FIELDSET> topic.


Every <LEGEND> element in a document is an object that can be manipulated through scripting. Note that scripting of the <LEGEND> element/object is only supported by Internet Explorer 4.0 in its Dynamic HTML object model as Netscape doesn't support the <LEGEND> element.

<LEGEND...> Properties
The <LEGEND...> element/object supports all of the standard Dynamic HTML properties (i.e. className, document, id, innerHTML, innerText, isTextEdit, lang, language, offsetHeight, offsetLeft, offsetParent, offsetTop, offsetWidth, outerHTML, outerText, parentElement, parentTextEdit, sourceIndex, style, tagName and title). Details of these can be found in the standard Dynamic HTML properties topics.
Additionally, the <LEGEND> element supports the following properties:

align
The align property directly reflects the value of the ALIGN attribute.

clientHeight
The clientHeight property reflects the height (in pixels) of the contents of the <LEGEND> element.

clientWidth
The clientWidth property reflects the width (in pixels) of the contents of the <LEGEND> element.

scrollHeight
The scrollHeight property reflects the contents of the <LEGEND> elements total scrollable height (in pixels).

scrollLeft
The scrollLeft property reflects a value representing the distance between the left-most edge of the element and the left-most visible edge of the element. While the contents of the <LEGEND> element are totally visible on the screen, the scrollLeft property is 0, only increasing if the left-most edge of the <LEGEND> elements contents are scrolled off the left hand edge of the current viewing window.

scrollTop
The scrollTop property returns a value that represents the distance between the top-most edge of the element and the top-most edge of the current viewing window. When used with the <LEGEND> element, the scrollTop property is a value indicative of the extent to which the referenced element has been scrolled vertically. If the contents of the <LEGEND> element are visible, then the scrollTop property will be 0, only increasing as the contents of the element are scrolled off the top of the current viewing window.

scrollWidth
Like the scrollHeight property, the scrollWidth property reflects a value that represents the total scrollable width of the contents of the <LEGEND> element.

<LEGEND...> Methods
The <LEGEND...> element/object supports all of the standard Dynamic HTML methods (i.e. click, contains, getAttribute, insertAdjacentHTML, insertAdjacentText, removeAttribute, scrollIntoView and setAttribute). Details of these can be found in the standard Dynamic HTML Methods topics.
Additionally, the <LEGEND> element supports the following methods:

blur
The blur event can be used to force the users focus away from the referenced <LEGEND> element, firing the onblur event.

focus
The focus method can be used to pass the users focus to the referenced <LEGEND> element, forcing the onfocus event to fire.

<LEGEND...> Events
The <LEGEND...> element/object supports all of the standard Dynamic HTML events (i.e. onclick, ondblclick, ondragstart, onfilterchange, onhelp, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup and onselectstart). Details of these can be found in the standard Dynamic HTML events topics.
Additionally, the <LEGEND> element supports the following events:

onblur
When the referenced <LEGEND> element loses the users focus, the onblur event is fired. On the fly form validation can make use of the onblur event to check form elements as the user is entering information.

onfocus
When the user passes the focus to any <LEGEND> element, the onfocus event is fired for that element.

Comments: