generic attributes


Description

This page describes the attributes that are shared between a large number of elements. Instead of repeating the same information across a lot of pages I combined these attributes on this single page. These attributes are mentioned in the descriptions of the elements, but they refer to this page for the description of the attribute.


Attributes

accesskey

This attribute assigns a key to access an element. The access key is a single character from the document character set.
Note. Authors should consider the input method of the expected reader when specifying an accesskey.

Pressing the access key of an element activates that specific element. What actually happens when the key is used, depends on the element. For example, when the key belongs to a link, the browser could load the resource the link points to. The key assigned to a button presses it, etc.

Return to the previous page


class

This attribute can be used with all HTML elements inside the 'BODY' section of the document. It is used to create different classes of a element, where each class can have its own properties.

For example, lets say we have defined this style sheet:

Source
<STYLE type="text/css">
DIV.sky {background: #A0A0F0; color: #404080;}
DIV.grass {background: green; color: #F0F000;}
</STYLE>

This creates two classes for the DIV element, "sky" and "grass", each with its own colors. Then you could use these classes:

Source
<DIV class="sky">
Just take a look up in the sky.
</DIV>
<DIV class="grass">
Or watch down an see the grass
</DIV>
 
Result
Just take a look up in the sky.
Or watch down an see the grass

You can omit the element name when you define the style sheet. This means that the class is not restricted to one specific element, but can be used with every element. For example, this style sheet defines the class ".nature":

Source
<STYLE type="text/css">
.nature {background: #00A000; color: #E0FFE0; font-size: 2em}
</STYLE>

Now you can use this style sheet with every element that you want:

Source
<TABLE border>
<TR>
<TD>A normal table cell</TD>
<TD class="nature">A table cell with a style sheet</TD>
</TR>
</TABLE>
<H4 class="nature">Isn't nature beautiful<H4>
 
Result
A normal table cell A table cell with a style sheet

Isn't nature beautiful

Return to the previous page


dir

This attribute specifies the default direction of directionally neutral text (i.e., text that doesn't have inherent directionality as defined in [UNICODE]) and the directionality of tables. Possible values are LTR for Left-to-right text or table, and RTL for Right-to-left text or table.

Return to the previous page


id

This attribute assigns a name to an element. This name must be unique in a document.


lang

This attribute specifies the language of the element's content and attribute values. The default value of this attribute is unknown. Here a some situations where a specified language can improve understanding of the contents :

values

The values that can be used for this attribute are language codes that identify natural languages. This can be spoken, written, or other languages used for the communication of information among people.
Computer languages are explicitly excluded from language codes.

[RFC1766] defines and explains the language codes that must be used in HTML documents.

Briefly, language codes consist of a primary code and a possibly empty series of subcodes:

        language-code = primary-code ( "-" subcode )*

Here are some sample language codes:

Two-letter primary codes are reserved for [ISO639] language abbreviations. Two-letter codes include fr (French), de (German), it (Italian), nl (Dutch), el (Greek), es (Spanish), pt (Portuguese), ar (Arabic), he (Hebrew), ru (Russian), zh (Chinese), ja (Japanese), hi (Hindi), ur (Urdu), and sa (Sanskrit).

Any two-letter subcode is understood to be a [ISO3166] country code.

Inheritance of language codes

An element inherits language code information according to the following order of precedence (highest to lowest):

In this example, the primary language of the document is French ("fr"). One paragraph is declared to be in Spanish ("es"), after which the primary language returns to French. The following paragraph includes an embedded Japanese ("ja") phrase, after which the primary language returns to French.

Source
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<HTML lang="fr">
<HEAD>
<TITLE>Un document multilingue</TITLE>
</HEAD>
<BODY>
 
Result
...Interpreted as French...
<P lang="es">...Interpreted as Spanish...
<P>...Interpreted as French again...
<P>...French text interrupted by<EM lang="ja">some
Japanese</EM>French begins here again...
</BODY>
</HTML>

Note. Table cells may inherit lang values not from its parent but from the first cell in a span. Please consult the section on alignment inheritance for details.

Return to the previous page


onblur

This attribute specifies a script function or script code that will be executed when the element loses focus. This means when the state changes from being the selected item to being non-selected. This happens when the user clicks on another item with the mouse, or uses the Tab-key to progress to the next item.

Return to the previous page


onclick

This attribute specifies a script function or script code that will be executed when the user clicks on the element with the mouse.

Return to the previous page


ondblclick

This attribute specifies a script function or script code that will be executed when the user doubleclicks on the element with the mouse.

Return to the previous page


onfocus

This attribute specifies a script function or script code that will be executed when the element gets focus. This means when the state changes from being a non-selected item to being the selected item. This happens when the user clicks on the item or by using the Tab-key to progress to the item.

Return to the previous page


onkeydown

This attribute specifies a script function or script code that will be executed when the user presses a key over an element.

Return to the previous page


onkeypress

This attribute specifies a script function or script code that will be executed when the user presses and releases a key over an element.

Return to the previous page


onkeyup

This attribute specifies a script function or script code that will be executed when the user releases a key over an element.

Return to the previous page


onmousedown

This attribute specifies a script function or script code that will be executed when the user presses the mouse button over an element.

Return to the previous page


onmousemove

This attribute specifies a script function or script code that will be executed when the user moves the mouse pointer within the element.

Return to the previous page


onmouseout

This attribute specifies a script function or script code that will be executed when the user moves the mouse pointer out of the element.

Return to the previous page


onmouseover

This attribute specifies a script function or script code that will be executed when the user moves the mouse pointer from outside the element over the element.

Return to the previous page


onmouseup

This attribute specifies a script function or script code that will be executed when the user releases the mouse button over an element.

Return to the previous page


tabindex

This attribute specifies the position of the current element in the tabbing order for the current document. This value must be a number between 0 and 32767. Leading zeros are ignored by the browser.

Return to the previous page


title

This attribute offers advisory information about the element for which it is set.

Return to the previous page
Statistics

  Copyright © 1996 - 2000 Rob Schlüter,   schluter@knoware.nl   (last updated 1999/01/17)