Most HTML tags rely on attributes to modify their behavior and make them more useful. With so many available tags and attributes, it's easy to forget which tag goes with which attributes. For instance, you may know that you want to set the padding value for a table, but you can't remember which tag takes the cellpadding attribute (the answer to this one is <table>).
The following table provides an alphabetical list of all attributes as listed in the HTML 4.01 specification. The "Related Elements" column provides a list of tags that can use that attribute. The table also lists:
Accepted values for each tag
Whether the attribute is required
A description of the attribute's use
Whether the attribute has been deprecated (indicated by a D in the "Depr." column)
Note that some attributes appear more than once in the list. This is due to the fact that they may be used differently or may take different values depending on the tag in which they are used.
Name |
Related elements |
Values |
Depr. |
Comment |
---|---|---|---|---|
TD, TH |
text |
Abbreviated name for table cell |
||
FORM |
list |
List of supported character sets |
||
INPUT, FORM |
MIME types |
List of MIME types for file upload |
||
A, AREA, BUTTON, INPUT, LABEL, LEGEND, TEXTAREA |
single character |
Assigns a shortcut key that brings focus to (activates) the element |
||
FORM |
URL |
Location of the CGI form processor on the server |
||
CAPTION |
top|bottom|left|right |
D |
Positions caption relative to table |
|
align |
APPLET, IFRAME, IMG, INPUT, OBJECT |
top|middle|bottom|left|right |
D |
Vertical or horizontal alignment |
align |
LEGEND |
top|bottom|left|right |
D |
Positions legend relative to fieldset |
align |
TABLE |
left|center|right |
D |
Table position relative to window |
align |
HR |
left|center|right |
D |
Horizontal alignment of rule |
align |
DIV, H1, H2, H3, H4, H5, H6, P |
left|center|right|justify |
D |
Alignment or justification of block element |
align |
COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, TR |
left|center|right|justify|char |
Horizontal alignment, character alignment, or justification |
|
BODY |
color |
D |
Color of active (selected) links |
|
APPLET |
text |
D |
Alternative text if the applet cannot be displayed |
|
alt(required) |
AREA, IMG |
text |
Alternative text that describes image if it cannot be displayed |
|
alt |
INPUT |
text |
Alternative text for graphic control if it cannot be displayed |
|
APPLET |
list of URLs |
D |
Comma-separated list of preload resources |
|
archive |
OBJECT |
list of URLs |
Space-separated list of preload resources |
|
TD, TH |
text |
Names a group of header cells for hierarchical table structures |
||
BODY |
URL |
D |
Location of tiling background graphic |
|
TABLE |
color |
D |
Background color for entire table |
|
bgcolor |
TR |
color |
D |
Background color for table row |
bgcolor |
TD, TH |
color |
D |
Background color for table cell |
bgcolor |
BODY |
color |
D |
Document background color |
IMG, OBJECT |
pixels or % |
D |
Width of border around linked images or objects |
|
border |
TABLE |
pixels (default=1) |
Width of frame around a table |
|
TABLE |
pixels or % (default=1) |
Spacing within cells |
||
cellspacing |
TABLE |
pixels or % (default=2) |
Spacing between cells |
|
COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, TR |
character |
The character along which elements are aligned, such as a decimal point |
||
COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, TR |
pixels or % |
Distance to first occurrence of the alignment character |
||
A, LINK, SCRIPT |
character set name |
Character encoding of the target resource |
||
INPUT |
(no explicit value) |
Sets the initial state of a radio button or checkbox to checked |
||
BLOCKQUOTE, Q |
url |
Location of source document for the quotation |
||
cite |
DEL, INS |
url |
Location of document containing explanation for edit |
|
All elements but BASE, BASEFONT, HEAD, HTML, META, PARAM, SCRIPT, STYLE, TITLE |
text |
The class (or list of classes) for the element (used with style sheets) |
||
OBJECT |
url |
URL for the specific implementation |
||
BR |
left|all|right|none (default=none) |
D |
Used to start flow of text after objects or images aligned against the margins |
|
APPLET |
applet file |
D |
Class name of the code to be executed |
|
OBJECT |
url |
Location of object's codebase (syntax varies by object) |
||
codebase |
APPLET |
url |
D |
URL from which the code is retrieved |
codetype |
OBJECT |
MIME type |
Media type of the code |
|
BASEFONT, FONT |
color |
D |
Text color |
|
FRAMESET |
list of measurements |
List of widths (in pixels, %, or relative * values) for columns in a frameset |
||
cols(required) |
TEXTAREA |
number (default=1) |
Width of a textarea form element, measured in number of characters |
|
colspan |
TD, TH |
number (default=1) |
Number of columns spanned by cell |
|
DIR, DL, MENU, OL, UL |
(no explicit value) |
D |
Reduces spacing between items in a list |
|
META |
text |
Content of meta information |
||
AREA |
x,y coords |
List of x,y coordinates used in an imagemap; syntax varies according to a given shape |
||
coords |
A |
x,y coords |
List of x,y coordinates used in a client-side imagemap |
|
OBJECT |
url |
Location of the data used for the object |
||
DEL, INS |
ISO date |
Date and time of change in ISO format (YYYY-MM-DDThh:mm:ssTZD) |
||
OBJECT |
(no explicit value) |
Declare but don't instantiate flag |
||
SCRIPT |
(no explicit value) |
UA may defer execution of script |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FRAME, FRAMESET, HR, IFRAME, PARAM, SCRIPT |
ltr|rtl (default=ltr) |
Specifies direction (left to right or right to left) for text |
||
dir |
BDO |
ltr|rtl (default=ltr) |
Direction for overridden text |
|
BUTTON, INPUT, OPTGROUP, OPTION, SELECT, TEXTAREA |
(no explicit value) |
Makes form control unavailable in a given context |
||
FORM |
Content-type |
Encoding type; defaults to application/x-www-form-urlencoded |
||
BASEFONT, FONT |
font name |
D |
Comma-separated list of font names |
|
LABEL |
ID value |
Associates the label with a control |
||
TABLE |
void|above|below|hsides|lhs|rhs|vsides|box|border |
Specifies which parts of the table frame to render |
||
FRAME, IFRAME |
1|0(default=1) |
Turns display of frame border on or off |
||
TD, TH |
ID references |
List of header cell IDs that are related to the cell |
||
IFRAME |
pixels or % |
Height of inline frame |
||
height |
IMG, OBJECT |
pixels or % |
Height of image or object (will resize original to match specified size) |
|
height (required) |
APPLET |
pixels or % |
D |
Initial height of applet window |
height |
TD, TH |
pixels or % |
D |
Height for cell |
A, AREA, LINK |
URL |
Location of target document or resource |
||
href |
BASE |
URL |
URL that serves as the base for all links in a document |
|
A, LINK |
two-character language code |
Identifies language of target document |
||
APPLET, IMG, OBJECT |
pixels |
D |
Amount of space held clear to the left and right of the element |
|
META |
name |
HTTP response header name |
||
All elements but BASE, HEAD, HTML, META, SCRIPT, STYLE, TITLE |
ID |
A unique ID name given to an instance of an element in a document |
||
IMG |
ismap |
Indicates image is a server-side imagemap |
||
OPTION |
text |
Defines a logical group of options for use in hierarchical menus |
||
label (required) |
OPTGROUP |
text |
Defines a logical group of options for use in hierarchical menus |
|
All elements butAPPLET, BASE, BASEFONT, BR, FRAME, FRAMESET, HR, IFRAME, PARAM, SCRIPT |
two-character language code |
Indicates language used in element |
||
SCRIPT |
script language |
D |
Predefined script language name |
|
BODY |
color |
D |
Color of links in the document |
|
IMG |
URL |
Link to long description of image contents (complements alt) |
||
longdesc |
FRAME, IFRAME |
URL |
Link to long description (complements title) |
|
FRAME, IFRAME |
pixels |
Height of top and bottom margins |
||
FRAME, IFRAME |
pixels |
Width of left and right margins |
||
INPUT |
number |
Maximum number of characters in a form field |
||
STYLE |
comma-separated list of media descriptors |
Element is designed for use with these media |
||
media |
LINK |
comma-separated list of media descriptors |
Selects style sheet for rendering these media |
|
FORM |
GET|POST (default=GET) |
HTTP method used to submit the form |
||
SELECT |
(no explicit value) |
Allows more than one option to be selected in a menu or scrolling list |
||
BUTTON, TEXTAREA, SELECT, INPUT, OBJECT |
text |
Names the parameter to be passed on to the forms processing application |
||
name |
APPLET |
text |
D |
Allows applets to find each other |
name |
FRAME, IFRAME |
text |
Names the frame for targeting |
|
name |
A |
text |
Creates named anchor (for linking to a specific spot on a page) |
|
name |
IMG |
text |
Name of image for reference in scripting |
|
name (required) |
MAP |
text |
Names a client-side imagemap for reference |
|
name (required) |
PARAM |
text |
Property name |
|
name |
META |
text |
Metainformation name |
|
AREA |
(no explicit value) |
Indicates an area of a client-side imagemap that has no associated link |
||
FRAME |
(no explicit value) |
When present, prevents users from resizing frames |
||
HR |
(no explicit value) |
D |
Turns off 3-D rendering of horizontal rules |
|
TD, TH |
(no explicit value) |
D |
Suppresses word wrap |
|
APPLET |
resource name |
D |
Serialized applet file |
|
A, AREA, BUTTON, INPUT, LABEL, SELECT, TEXTAREA |
script |
When focus is removed from an element |
||
INPUT, SELECT, TEXTAREA |
script |
When element value changes |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer button is clicked |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer button is double-clicked |
||
A, AREA, BUTTON, INPUT, LABEL, SELECT, TEXTAREA |
script |
When focus is applied to an element |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a key is pressed down |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a key is pressed and released |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a key is released |
||
FRAMESET |
script |
When all the frames have been loaded |
||
onload |
BODY |
script |
When the document has been loaded |
|
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer button is pressed down |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer is moved within the element |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer is moved out of the element's space |
||
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer was moved onto the element's space |
||
onmouseup |
All elements but APPLET, BASE, BASEFONT, BDO, BR, FONT, FRAME, FRAMESET, HEAD, HTML, IFRAME, ISINDEX, META, PARAM, SCRIPT, STYLE, TITLE |
script |
When a pointer button is released |
|
FORM |
script |
When the form is reset |
||
INPUT, TEXTAREA |
script |
When some text is selected |
||
FORM |
script |
When the form is submitted |
||
FRAMESET |
script |
When all the frames have been removed |
||
BODY |
script |
When the document has been removed |
||
HEAD |
URL |
A metadata profile (dictionary) |
||
ISINDEX |
text |
D |
Initial message in an isindex search field |
|
TEXTAREA, INPUT |
(no explicit value) |
Prevents editing of initial value in a form text field (textarea, text password) |
||
A, LINK |
link types |
Comma-separated list of forward link types |
||
A, LINK |
link types |
Comma-separated list of reverse link types |
||
FRAMESET |
list of measurements |
Comma-separated list of heights for the rows of a frameset (in pixels, %, or relative * values) |
||
rows (required) |
TEXTAREA |
number |
The number of visible rows in a textarea field |
|
TD, TH |
number(default=1) |
The number of rows spanned by cell |
||
TABLE |
none|groups|rows|cols|all |
Specifies where rules are rendered between rows and columns of a table |
||
META |
text |
Scheme to be used in interpreting the content (varies by context) |
||
TD, TH |
row|col|rowgroup|colgroup |
Set of data cells for which the current header cell provides header information |
||
FRAME, IFRAME |
yes|no|auto (default=auto) |
Indicates when a scrollbar should appear |
||
OPTION |
selected |
Defines initial state of an option as selected |
||
shape (required) |
AREA |
shape |
Shape description (rect, circ, poly) used for interpretation of coordinates (for use in client-side imagemaps) |
|
A |
shape |
For use with client-side imagemaps |
||
HR |
pixels |
D |
Specifies thickness of horizontal rule |
|
size |
FONT |
number |
D |
Font size: absolute (1-7) or relative (+1, -1, etc.) |
size |
INPUT |
number |
Specific to each type of field |
|
size (required) |
BASEFONT |
number |
D |
Base font size for FONT elements (absolute or relative size notation) |
size |
SELECT |
number |
Number of visible rows in scrolling list |
|
COL |
number (default=1) |
COL attributes affect N columns |
||
span |
COLGROUP |
number (default=1) |
Number of columns in group |
|
SCRIPT |
url |
URL for an external script |
||
src |
INPUT |
url |
URL for image used as a form button |
|
src |
FRAME, IFRAME |
url |
Source of frame content |
|
src (required) |
IMG |
url |
URL of image file |
|
OBJECT |
text |
Message to show while loading |
||
OL |
number |
D |
The number an ordered list should begin counting from |
|
All elements but BASE, BASEFONT, HEAD, HTML, META, PARAM, SCRIPT, STYLE, TITLE |
style syntax |
Associated style info |
||
TABLE |
text |
Provides description of table contents for nonvisual browsers |
||
A, AREA, BUTTON, INPUT, OBJECT, SELECT, TEXTAREA |
number |
Position in tabbing order |
||
A, AREA, BASE, FORM, LINK |
window name |
Targets the window or frame to load the target document. The predefined target names are _blank, _self, _parent, _top |
||
BODY |
color |
D |
Document text color |
|
STYLE |
text |
Title for the style |
||
title |
All elements but BASE, BASEFONT, HEAD, HTML, META, PARAM, STYLE, TITLE |
text |
Specifies an advisory title that may be rendered specially by nonvisual browsers |
|
A, LINK |
MIME type |
Advisory content type |
||
type |
OBJECT |
MIME type |
Content type for data |
|
type |
PARAM |
MIME type |
Content type for value when valuetype=ref |
|
type (required) |
SCRIPT |
MIME type |
Content type of script language |
|
type (required) |
STYLE |
MIME |
Content type of style language (defaults to text/css) |
|
type (required) |
INPUT |
text|password|checkbox|radio|submit|reset|file|hidden|image (default=text) |
The kind of widget that is needed |
|
type |
LI |
disc|square|circleor 1|A|a|I|i (default=disc) |
D |
The bullet style or numbering scheme for a list item (depending on context) |
type |
OL |
1|A|a|I|i (default=1) |
D |
Numbering style |
type |
UL |
disc|square|circle (default=disc) |
D |
Bullet style |
type (required) |
BUTTON |
button|submit|reset (default=submit) |
For use as form button |
|
IMG, INPUT, OBJECT |
url |
A fragment identifier that points to the map element for a client-side imagmap |
||
COL, COLGROUP, TBODY, TD, TFOOT, TH, THEAD, TR |
top|middle|bottom|baseline (default=middle) |
Vertical alignment in cells |
||
OPTION |
alphanumeric text |
The value of the option when selected; defaults to content of the option container |
||
value |
PARAM |
alphanumeric |
Property value |
|
value |
INPUT, BUTTON |
value |
Value of input element, which is passed on to the forms processing program |
|
value |
LI |
number |
D |
Resets sequence number |
PARAM |
data|ref|object |
How to interpret value |
||
HTML |
url |
D |
Link to DTD for the document |
|
BODY |
color |
D |
Color of visited links |
|
APPLET, IMG, OBJECT |
pixels |
D |
Amount of space held clear above and below an element |
|
HR |
pixels or % |
D |
Length of horizontal rule |
|
width |
IFRAME |
pixels or % |
Frame width |
|
width |
IMG, OBJECT |
pixels or % |
Size of image or object; browser resizes elements to match specified values |
|
width |
TABLE |
pixels or % |
Table width |
|
width (required) |
APPLET |
pixels or % |
D |
Initial width of applet |
width |
COL |
pixels, %, or * |
Column width specification |
|
width |
COLGROUP |
pixels, %, or * |
Default width for enclosed COLs |
|
width |
TD, TH |
pixels or % |
D |
Width for cell |
width |
PRE |
number |
D |
Copyright © 2002 O'Reilly & Associates. All rights reserved.