Elements and attributes that the W3C would like to discourage you from using are marked with a D (for deprecated) or an F (for frameset). Deprecated items can only be used if you've specified the DOCTYPE for transitional or frameset (X)HTML. Frameset items can only be used in frameset (X)HTML. Thus, if your intention is to write strict (X)HTML, you should use only those elements and attributes with nothing in the Vers. column. For more information on choosing and then specifying an appropriate DOCTYPE, consult Versions, flavors, and DOCTYPE on page 40 and Starting Your Web Page on page 56.
(X)HTML Elements and Attributes
Tag/Attribute(S) | Description | Vers. |
---|
--MOST TAGS-- | The following attributes may be used with most (X)HTML tags | |
class
| For identifying a set of tags in order to apply styles to them (pp. 63, 64, 65) | |
event
| For triggering a script (p. 314). Also see Intrinsic Events on page 418 | |
id
| For identifying particular tags so that they can be linked to, styled, or scripted with JavaScript (pp. 63, 64, 65, 106) | |
lang
| For specifying the language an element is written in (p. 338) | |
style
| For adding local style sheet information (p. 134) | |
title
| For labeling elements with tool tips (p. 68) | |
!-- | For inserting invisible comments (p. 67) | |
!DOCTYPE | Theoretically required. For indicating the version of (X)HTML used (p. 56) | |
a | For creating links and anchors (p. 104) | |
accesskey
| For adding a keyboard shortcut to a link (p. 112) | |
event
| For triggering a script (p. 314) | |
href
| For specifying the URL of a page or the name of an anchor that a link goes to | |
name
| For marking a specific area of a page that a link might jump to (p. 106) | |
tabindex
| For defining the order in which the Tab key takes the visitor through links and form elements (p. 113) | |
target
| For specifying the window or frame where a link should open (pp. 108, 109) | D |
abbr | For explaining the meaning of abbreviations (p. 78) | |
acronym | For explaining the meaning of acronyms (p. 78) | |
address | For formatting the email address of the Web page designer (p. 70) | |
applet | For inserting applets (p. 308) | D |
code
| For specifying the URL of the applet's code | D |
width, height
| For specifying the width and height of an applet | D |
area | For specifying the coordinates of image maps (p. 117) | |
accesskey
| For adding a keyboard shortcut to a particular region of the map | |
alt
| For giving information about an area | |
coords
| For giving the coordinates of an area in an image map | |
HRef
| For specifying the destination URL of a link in an area in an image map | |
nohref
| For making a click in an image map have no effect | |
shape
| For specifying the shape of an area in an image map | |
target
| For specifying the window or frame where a link should open | D |
b | For displaying text in boldface (p. 70) | |
base | | |
HRef
| For specifying the URL to be used to generate relative URLs (p. 109) | |
target
| For specifying the default target for the links on the page (p. 109) | D |
basefont | For specifying default font values for a page (see Web site) | D |
color
| For specifying the default color for text | D |
face
| For specifying the default font for text | D |
size
| For specifying the default size for text | D |
big | For making text bigger than the surrounding text (p. 71) | |
blockquote | For setting off a block of text on a page (p. 74) | |
cite
| For giving the URL of the source of the quote | |
body | For enclosing the main content area of a page (p. 58) | |
alink, link, vlink
| For specifying the color of active links, new links, and visited links (see Web site) | D |
background
| For specifying a background image (see Web site) D | |
bgcolor
| For specifying the background color (see Web site) | D |
text
| For specifying the color of text (see Web site) | D |
br | For creating a line break (p. 66) | |
clear
| For stopping text wrap (p. 98) | D |
button | For creating buttons (pp. 273, 275, 316) | |
accesskey
| For adding a keyboard shortcut to a button | |
disabled
| For graying out a button until some other event occurs | |
event
| For associating the button with a script | |
name
| For identifying the data sent with a button, or for identifying the button itself (perhaps for a JavaScript function) | |
type
| For using the button as a form element | |
value
| For specifying the data that should be submitted when the button is clicked | |
caption | For creating a caption for a table (p. 229) | |
align
| For positioning the caption above or below the table | D |
center | For centering text, images, or other elements (p. 79) | D |
cite | For marking text as a citation (p. 70) | |
code | For marking text as computer code (p. 72) | |
col | For joining columns in a table into a non-structural group (p. 246) | |
align, valign
| For specifying the alignment of columns in a column group | |
span
| For specifying the number of columns in a column group | |
width
| For specifying a column's width | |
colgroup | For joining columns in a table into a structural column group (p. 246) | |
align, valign
| For specifying the alignment of columns in a column group | |
span
| For specifying the number of columns in a column group | |
width
| For specifying the default width for the enclosed col elements | |
dd | For marking a definition in a list (p. 223) | |
del | To mark deleted text by striking it out (p. 77) | |
div | For dividing a page into block-level sections (pp. 64, 170) | |
align
| For aligning a given division to the left, right, or center | D |
class
| For identifying a group of divisions (so that you can apply styles to them all in one fell swoop) | |
id
| For identifying particular divisions (so they can be linked, styled, or scripted) | |
dl | For creating a definition list (p. 223) | |
dt | For marking a term to be defined in a list (p. 223) | |
em | For emphasizing text, usually with italics (p. 70) | |
embed | For adding multimedia (pp. 286, 302) | * |
autostart
| For making a multimedia event begin automatically | * |
controls
| For displaying the play, pause, rewind buttons | * |
loop
| For determining if the multimedia event should play more than once | * |
src
| For specifying the URL of a multimedia file | * |
width, height
| For specifying the size of the embedded multimedia player | * |
fieldset | For grouping a set of form elements together (p. 260) | |
font | For changing the size, face, and color of the text (see Web site) | D |
color
| For changing text color | D |
face
| For changing text font | D |
size
| For changing text size | D |
form | For creating fill-in forms (p. 254) | |
action
| For giving the URL of the script that will process the form data | |
enctype
| For making sure files are sent to the server in the proper format (pp. 259, 270) | |
method
| For specifying how data should be sent to the server | |
frame | For creating frames (see Web site) | F |
frameborder
| For displaying or hiding frame borders (see Web site) | F |
longdesc
| For linking to a document with more information (see Web site) | F |
name
| For naming a frame so it can be used as a target (see Web site) | F |
noresize
| For keeping users from resizing a frame (see Web site) | F |
marginwidth, marginheight
| For specifying a frame's left and right, and top and bottom margins (see Web site) | F |
scrolling
| For displaying or hiding a frame's scrollbars (see Web site) | F |
src
| For specifying the initial URL to be displayed in frame (see Web site) | F |
target
| For specifying which frame a link should be opened in (see Web site) | F |
title
| For indicating a frame's purpose (see Web site) | F |
frameset | For defining a frameset (see Web site) | F |
cols
| For determining the number and size of frames (see Web site) | F |
frameborder
| For displaying or hiding frame borders (see Web site) | F |
rows
| For determining the number and size of frames (see Web site) | F |
h1, h2, h3, h4, h5, h6 | For creating headers (p. 61) | |
align
| For aligning headers | D |
head | For creating the head section, which contains information about the page, including the title, author, keywords, style sheets, and scripts (p. 58) | |
HR | For creating horizontal rules (p. 101) | |
align
| For aligning horizontal rules | D |
noshade
| For displaying horizontal rules without shading | D |
size
| For specifying the height of a horizontal rule | D |
width
| For specifying the width of a horizontal rule | D |
html | For identifying a text document as an (X)HTML document (p. 56) | |
xmlns | For specifying the xhtml namespace | |
i | For displaying text in italics (p. 70) | |
iframe | For creating floating frames (see Web site) | D |
align
| For aligning floating frames | D |
frameborder
| For displaying or hiding frame borders (see Web site) | D |
height
| For specifying the height of a floating frame | D |
name
| For specifying the name of the floating frame, to be used as a target | D |
width, height
| For specifying the size of a floating frame | D |
scrolling
| For displaying or hiding scrollbars (see Web site) | D |
src
| For specifying the URL of the initial page | D |
img | For inserting images on a page (p. 90) | |
align
| For aligning images (p. 100) and for wrapping text around images (pp. 96, 97) | D |
alt
| For offering alternate text that is displayed if the image is not (p. 91) | |
border
| For specifying the thickness of the border, if any (pp. 90, 114) | D |
hspace, vspace
| For specifying the amount of space above and below, and to the sides of an image (p. 99) | D |
src
| For specifying the URL of an image (p. 90) | |
usemap
| For specifying the image map that should be used with the referenced image (pp. 117, 118) | |
width, height
| For specifying the size of an image so that the page is loaded more quickly, or for scaling (pp. 92, 93, 94) | |
input | For creating form elements (pp. 262, 263, 265, 268, 270, 271, 272, 274) | |
accesskey
| For adding a keyboard shortcut to a form element (p. 278) | |
align
| For aligning form elements | D |
checked
| For marking a radio button or check box by default (pp. 265, 268) | |
disabled
| For graying out form elements until some other event occurs (p. 279) | |
event
| For triggering a script with an event like onfocus, onblur, etc. | |
maxlength
| For specifying the maximum number of characters that can be entered in a form element (pp. 262, 263) | |
name
| For identifying data collected by an element | |
size
| For specifying the length of a text or password box (pp. 262, 263) | |
src
| For specifying the URL of an active image (p. 276) | |
readonly
| For keeping visitors from changing certain form elements (p. 280) | |
tabindex
| For specifying the order in which the Tab key should take a visitor through the links and form elements (p. 277) | |
type
| For specifying if a form element is a text box, password box, radio button, checkbox, hidden field, submit button, reset button or active image | |
value
| For specifying the default data in a form element | |
ins | For marking inserted text with an underline (p. 77) | |
kbd | For marking keyboard text (p. 72) | |
label | For labeling form elements (p. 264) | |
for
| For specifying which form element the label belongs to | |
legend | For labeling fieldsets (p. 260) | |
align
| For aligning legends | D |
li | For creating a list item (p. 216) | |
type
| For determining which symbols or type of numerals should begin the list item | D |
value
| For determining the initial value of the first list item | D |
link | For linking to an external style sheet (p. 129) | |
href
| For specifying the URL of the style sheet | |
media
| For noting a style sheet's purpose (pp. 133, 204, 210) | |
title
| For labeling alternate style sheets (p. 130) | |
type
| For noting a style sheet's MIME type | |
rel
| For indicating that a style sheet is preferred or alternate (pp. 129, 130) | |
map | For creating a client-side image map (p. 117) | |
name
| For naming a map so it can be referenced later | |
meta | | |
content
| For adding extra information about the Web page itself (pp. 310, 320, 330, 363, 364, 365, 366) | |
http-equiv
| For creating automatic jumps to other pages (p. 310), setting the default scripting language (p. 320), and declaring the character encoding (p. 330) | |
name
| For identifying extra information about the Web page (pp. 363, 364, 365, 366) | |
noframes | For providing alternatives to frames (see Web site) | F |
noscript | For providing alternatives to scripts (p. 317) | |
object | For embedding objects in Web pages (pp. 286, 288, 290, 302, 304, 305, 306, 308) | |
align
| For aligning objects | D |
border
| For creating (or hiding) a border around an object | D |
classid
| It is supposed to be a URL that specifies the location of an object's "implementation" but currently is incorrectly used by Microsoft to call its ActiveX controls | |
codebase
| It is supposed to be the base URL for resolving relative URLs in the other attributes, but in fact is mostly used to specify the location of the desired multimedia player | |
data
| For identifying the source of the multimedia file to be embedded | |
hspace, vspace
| For specifying the amount of space around an object | D |
name
| For identifying the object (e.g., so it can be scripted) | |
standby
| For displaying a message as the object is loading | |
type
| For noting the object's MIME type | |
width, height
| For specifying the dimensions of the object's box | |
ol | For creating ordered lists (p. 216) | |
type
| For specifying the kind of numerals that should begin each list item | D |
start
| For specifying the initial value of the first list item | D |
optgroup | For dividing a menu into submenus (p. 267) | |
disabled
| For graying out menu options until some other event occurs | |
label
| For specifying how the option should appear in the menu | |
option | For creating the individual options in a form menu (p. 266) | |
disabled
| For graying out menu options until some other event occurs | |
label
| For specifying how the option should appear in the menu | |
selected
| For making a menu option be selected by default in a blank form | |
value
| For specifying the initial value of a menu option | |
p | For creating new paragraphs (p. 62) | |
align
| For aligning paragraphs | D |
param | For setting properties of an object (pp. 286, 288, 290, 302, 304, 305, 306, 308) | |
name
| For identifying the kind of property | |
value
| For setting the value of the named property | |
pre | For maintaining the spaces and returns that were in the original text (p. 73) | |
q | For quoting short passages of text (p. 74) | |
cite
| For giving the URL of the source of the quote | |
s | (Same as strike) For displaying text with a line through it (see Web site) | D |
samp | For displaying sample textin a monospaced font (p. 72) | |
script | For adding "automatic" scripts to a page (p. 312) | |
charset
| For specifying the character set an external script is written in (p. 313) | |
language
| For specifying the scripting language the script is written in | D |
src
| For referencing an external script (p. 313) | |
type
| For specifying the scripting language the script is written in | |
select | For creating menus in forms (p. 266) | |
disabled
| For graying out menu options until some other event occurs | |
name
| For identifying the data collected by the menu | |
multiple
| For allowing users to choose more than one option in the menu | |
size
| For specifying the number of items initially visible in the menu (and for displaying the menu as a list) | |
small | For decreasing the size of text (p. 71) | |
span | For creating custom character styles (p. 65) | |
class
| For naming custom styles | |
id
| For identifying particular (X)HTML elements so that they can be linked to, styled, or controlled with a script | |
strike | (Same as the s element) For displaying text with a line through it (see Web site) | D |
strong | For emphasizing text logically, usually in boldface (p. 70) | |
style | For adding style sheet information to a page (p. 131) | |
media
| For indicating a style sheet's purpose (pp. 133, 204, 210) | |
type
| For indicating a style sheet's MIME type | |
sub | For creating subscripts (p. 76) | |
sup | For creating superscripts (p. 76) | |
table | For creating tables (p. 229) | |
align
| For aligning an entire table with respect to the window (p. 234) | D |
bgcolor
| For specifying the background color of the table (p. 240) | D |
border
| For specifying the thickness, if any, of the border (p. 230) | |
cellpadding
| For setting the space between a cell's contents and its borders (p. 242) | |
cellspacing
| For setting the amount of space between cells (p. 242) | |
frame
| For displaying external borders (p. 249) | |
rules
| For displaying internal borders (p. 250) | |
width
| For specifying the size of the table (p. 232) | |
tbody | For identifying the body of the table (in contrast with the header (thead) or footer (tfoot) (p. 248) | |
align, valign
| For aligning the contents of the body of the table | |
bgcolor
| For changing the color of an entire row (p. 240) | D |
TD, th | For creating regular and header cells, respectively, in a table (p. 229) | |
align, valign
| For aligning a cell's contents horizontally or vertically (p. 238) | |
bgcolor
| For changing the background color of a cell (p. 240) | D |
char
| For aligning the contents of a cell with respect to a character (p. 239) | |
colspan
| For spanning a cell across more than one column (p. 244) | |
nowrap
| For keeping a cell's contents on one line (p. 251) | D |
rowspan
| For spanning a cell across more than one row (p. 245) | |
width, height
| For specifying the size of the cell (p. 232) | D |
textarea | For creating text block entry areas in a form (p. 269) | |
accesskey
| For adding a keyboard shortcut to a text area | |
disabled
| For graying out a text block until some other event occurs | |
name
| For identifying the data that is gathered with the text block | |
readonly
| For protecting a text area's contents (p. 280) | |
rows, cols
| For specifying the number of rows and columns in the text block | |
tfoot, thead | For identifying the footer and header area of a table (p. 248) | |
align, valign
| For aligning the footer or header cells (p. 238) | |
bgcolor
| For changing the color of an entire row (p. 240) | D |
title | Required. For creating the title of the page in the browser's title bar area (p. 60) | |
TR | For creating rows in a table (p. 229) | |
align, valign
| For aligning the contents of a row horizontally or vertically (p. 238) | |
bgcolor
| For changing the color of an entire row (p. 240) | D |
tt | For displaying text in a monospaced font (p. 72) | |
u | For displaying text with a line underneath it (see Web site) | D |
ul | For creating unordered lists (p. 216) | |
type
| For specifying the markers that should precede each list item | D |