Following is a listing of all HTML elements included in HTML 4.01, along with their principal allowed attributes. Examples are provided where they might be helpful.
To help you understand the references that follow (and so I don't have to explain them every time), here's a legend of abbreviations used in this reference:
Attribute values:
attribute="url" |
Absolute or relative URL |
attribute="text" |
Text string |
attribute="n" |
Numerical integer |
attribute="n%" |
Percentage (for example, "75%") |
attribute="value1|value2|value3" |
Alternate values for the same attribute |
attribute="#rrggbb" |
Hexadecimal color code |
attribute="MIME type" |
Internet Media Type |
Element status:
(D) = element/attribute deprecated in HTML 4.01
(4.0) = element/attribute introduced with HTML 4.0
Element type:
B = block element
I = inline element
E = empty element
C = container element
Allowed content:
B = block elements
I = inline elements
dna = does not apply
Start/End tags:
R/R = start/end tags both required
R/O = start tags required; end tags optional (implied)
O/O = start/end tags both optional
dna = does not apply
Type: I,C |
Content: I |
Start/End: R/R |
A (Anchor) provides a means to insert hypertext links into HTML documents.
href="url" |
See below |
name="targetname" |
See below |
rel="url" |
Optional |
rev="url" |
Optional |
target="framename" (4.0) |
Optional |
accesskey="character" (4.0) |
Optional |
tabindex="n" |
Optional |
HREF or NAME is required. HREF specifies the link URL. NAME specifies a target anchor that another link can jump to (either from the same or another Web page). TARGET targets a frame, causing the linked document to be retrieved in the named frame (see the FRAMESET element). ACCESSKEY allows you to assign a shortcut key to a link. TABINDEX lets you alter the position of an A element in the document's tabbing order.
Type: I,C |
Content: I |
Start/End: R/R |
ABBR marks an abbreviation and optionally provides the full term. Using this element to spell out abbreviations can, however, assist search engine robots in indexing your page.
title="full term" |
optional |
TITLE can be used to specify the spelled-out term. Browsers may display the TITLE attribute value in a tooltip when the mouse pointer is passed over the element.
Type: I,C |
Content: I |
Start/End: R/R |
ACRONYM marks an acronym and optionally provides the full term. Currently, this element is not supported by the latest versions of either Internet Explorer (5.01) or Netscape Navigator (4.73). Using this element to spell out acronyms can, however, assist search engine robots in indexing your page.
title="full term" |
optional |
TITLE can be used to specify the spelled-out term. Browsers may display the TITLE attribute value in a tooltip when the mouse pointer is passed over the element.
An acronym is an abbreviation that is pronounced as though it is a word, rather than initials. Examples of acronyms might be sonar, radar, NATO, CERN, and so on. Acronyms are also abbreviations, so you can use either the ABBR or the ACRONYM element.
Internet Explorer 6 supports the ABBR element but not the ACRONYM element.
Type: B,C |
Content: I |
Start/End: R/R |
ADDRESS adds author and contact information at the end of a document. In most cases, text in an ADDRESS element is italicized. It's common to precede the ADDRESS element with an HR element. Name, email, mailto link, URL, and last date updated can be included.
Only inline elements can be nested inside the ADDRESS element. While browsers recognize use of the ALIGN attribute to center the ADDRESS element's content, it is not allowed by HTML 4.01. To center (or right-align) ADDRESS element content in a way that is valid in HTML 4.01, either use a style or nest the ADDRESS element inside of a CENTER element or a center-aligned DIV element. Both the CENTER element and the ALIGN attribute are deprecated in these instances.
Type: B,C |
Content: I,B |
Start/End: R/R |
APPLET runs a Java applet from within an HTML document. In HTML 4, the APPLET element is deprecated in favor of the OBJECT element.
code="classfile" |
Required |
width="n" |
Required |
height="n" |
Required |
codebase="url" |
Optional |
alt="text" |
Optional |
name="applet name" |
Optional |
align="top|middle|bottom|left|right" |
Optional |
hspace="n" |
Optional |
vspace="n" |
Optional |
CODE references the file name for the applet's compiled subclass, which must be relative to the applet's base URL. CODEBASE specifies the applet's base URL (if other than the HTML document's URL). ALT provides alternative text. NAME allows applets on the same page to communicate with each other.
Type: E |
Content: dna |
Start/End: dna |
PARAM is an empty element used to pass named parameters to an applet. It's nested inside the APPLET element.
name="parameter name" |
Required |
value="parameter value" |
Required |
NAME specifies a name token, which must start with a letter (A to Z or a to z) and can be followed by any number of letters, digits, hyphens, or periods. Character entities cannot be included. VALUE contains the parameter that's being passed to the applet.
Example:
<applet code="password.class" width="500" height="32"> <param name="pass" value="password.html"> <param name="nopass" value="nopassword.html"> </applet>
Type: I,C |
Content: I |
Start/End: R/R |
B (Bold) specifies that nested text should be displayed in a bold font.
Type: E |
Content: dna |
Start/End: dna |
BASEFONT is used to reset base font characteristics. Multiple BASEFONT elements can be inserted into an HTML document—the new base font characteristics apply until a new BASEFONT element is inserted. BASEFONT is deprecated in favor of using styles.
size="n" |
Required |
color="#rrggbb|colorname" |
Optional |
face="font[,font2][,font3]" (4.0) |
Optional |
SIZE specifies an absolute or relative font size. A relative font size is specified relative to either the default base font size (3) or base font size set previously using the BASEFONT element. COLOR sets the font color, either with a hexadecimal color code (#rrggbb) or a color name (black, white, aqua, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, and yellow). FACE specifies a font name or a comma-separated list of font names that can be used to display the font.
The latest versions of the Mozilla, Netscape, and Opera browsers no longer support use of the BASEFONT element. To change the display characteristics of the default base font, styles should be used instead.
If used, only absolute font sizes should be set using the BASEFONT element. All versions of Internet Explorer treat a relative font size of +1 as being equal to an absolute font size of 1 when set using the BASEFONT element.
Type: C,I |
Content: I |
Start/End: R/R |
BDO allows authors to override the bi-directional algorithm for text phrases.
dir="ltr|rtl" |
Required |
lang="language code" |
Optional |
FIND IT ONLINE
DIR sets either left-to-right ("ltr") or right-to-left ("rtl") direction. LANG specifies a language code. For further guidance in using this element, see www.w3.org/TR/html4/struct/dirlang.html. For a listing of two-character language codes, see www.unicode.org/unicode/onlinedat/languages.html.
Example:
<p><bdo dir="ltr">0 1 2 3 4 5 6 7 8 9</bdo></p> <p><bdo dir="rtl">9 8 7 6 5 4 3 2 1 0</bdo></p>
Type: C,I |
Content: I |
Start/End: R/R |
BIG displays text in a font that's one size bigger than the base font. To display even bigger fonts, multiple instances of the BIG element can be nested within each other.
Type: C,B |
Content: B |
Start/End: R/R |
BLOCKQUOTE displays a block of text indented in from the left and right margins. It can be used to display an actual block quote or simply as a means of indenting text in from the margins.
cite="URL" |
Optional |
CITE allows you to specify a URL to designate the source of the quote, but current browsers do nothing with it.
According to the HTML 4.01 specification, only block elements, and not inline elements or raw text, should be nested directly inside of a BLOCKQUOTE element, although browsers don't seem to care. Use of the BLOCKQUOTE element simply as a formatting device, to indent nested text and elements, rather than to present block quotations, is deprecated in favor of using styles in HTML 4.01.
Type: C |
Content: B |
Start/End: O/O |
The BODY element is nested directly inside of the HTML element and contains the body of an HTML document. With the exception of the FRAMESET element (which replaces the BODY element), everything not included in the HEAD element must go inside the BODY element.
background="url" (D) |
Optional |
bgcolor="#rrggbb|colorname" (D) |
Optional |
text="#rrggbb|colorname" (D) |
Optional |
link="#rrggbb|colorname" (D) |
Optional |
vlink="#rrggbb|colorname" (D) |
Optional |
alink="#rrggbb|colorname" (D) |
Optional |
These attributes are all deprecated in favor of using styles. BACKGROUND specifies the URL of a background image. BGCOLOR specifies a background color (using a hexadecimal color code or a color name). TEXT, LINK, VLINK, and ALINK assign colors to the base text font, hypertext links, visited links, and activated links, respectively.
Type: E,B |
Content: dna |
Start/End: dna |
BR inserts a line break. This can be used for formatting lists or lines of poetry—anywhere you want a single line break between lines. (Most "block" elements, such as the P element, are followed by two line breaks.)
clear="left|right|all" (Deprecated) |
Optional |
CLEAR stops text from wrapping around a left-or right-aligned image, with "left" moving text (or other elements) down until the left margin is clear, "right" until the right margin is clear, and "all" until both the left and right margins are clear. The CLEAR attribute is deprecated in favor of using styles to achieve the same result.
Type: C,B |
Content: B |
Start/End: R/R |
CENTER causes any included text or elements to be centered. This element was originally a Netscape extension to HTML but has since been defined in HTML 3.2 as equivalent to <div align="center">...</div>. Be aware, however, that some earlier browsers may support the CENTER element, but not the DIV element.
Type: C,I |
Content: I |
Start/End: R/R |
CITE renders a citation or reference to other sources. Your best bet may be to use I or EM instead, since browsers don't do anything special with this element, other than render it in italics.
Type: C,I |
Content: I |
Start/End: R/R |
CODE renders program or computer code. It is intended for rendering short phrases or words of code (the PRE tag should be used to render blocks of program code). This element should be displayed in a monospaced font. Your best bet may be to simply use the TT tag instead, since browsers don't do anything special with this element, other than to render it in a monospaced font.
In HTML, a "comment" can be inserted by preceding the comment with <!-- and ending it with -->.
Example:
<!-- The following code is commented out and won't be dis- played <h1 align="right">My Favorite Schlock Movies</h1> -->
Type: C,I |
Content: I |
Start/End: R/R |
DEL marks text for deletion, which should then be displayed as strikeout text. It is used in conjunction with the INS (Insert) element to mark document revisions. If all you want to do is mark strikeout text, your best bet is to use the STRIKE tag instead, because it is more likely to be supported by earlier browsers.
cite="url" |
Optional |
datetime="datetime" |
Optional |
FIND IT ONLINE
CITE designates the URL of a source document or message that is cited as the source, reason, or authority for the deletion. DATETIME is not recognized by any browsers and is primarily intended for use by group authoring software to specify the time and date of revisions. Refer to the DEL section in the HTML 4.01 specification at www.w3.org/TR/html4/struct/text.html#edef-del for further details.
Type: C,I |
Content: I |
Start/End: R/R |
DFN is used to display the defining instance of a term. Internet Explorer displays it in italics, but Navigator entirely ignores it. Your best bet is to use I or EM tags instead.
Type: C,B |
Content: LI,B |
Start/End: R/R |
DIR is deprecated in HTML 4.01, in favor of using the UL element. Since browsers display these elements identically, as a bulleted list, there is no reason to use the DIR element.
Type: C,B |
Content: I,B |
Start/End: R/R |
DIV defines a "division" within an HTML document, which can include any other HTML block and inline elements.
align="left|right|center|justify" |
Optional |
The DIV element, by itself, can only be used to horizontally align (using the ALIGN attribute) multiple lines of text and elements. In combination with style sheets, however, it becomes much more powerful. The DIV element should not be nested inside any element other than the BODY element.
Type: C,B |
Content: B |
Start/End: R/R |
DL allows you to create a definition list (also called a glossary). The DT (Definition Term) and DD (Definition Data) elements are nested inside of the DL element to create the list. Another use of the DL element is to mark up dialogue, with the DT element identifying the speaker and the DD element containing the dialogue.
Type: C,B |
Content: I |
Start/End: R/O |
DT specifies the "term" element in a definition item. It's always nested inside the DL element. The DT element is not an empty element; it is a container element that has an implied end tag.
Type: C,B |
Content: I,B |
Start/End: R/O |
DD specifies the "data" element in a definition item; it contains the actual "definition" that's included in the list. It's displayed indented under the DT item. Normally, it follows a DT element, but can be included by itself. The DD element is not an empty element, but a container element that has an implied end tag.
Type: C,I |
Content: I |
Start/End: R/R |
EM emphasizes text by displaying it in italics. This element should always display in a browser identically to the I element—the only difference being that the EM element is a logical element, whereas the I element is a literal element.
Type: C,I |
Content: I |
Start/End: R/R |
FONT sets font size, color, and face properties. It was deprecated in HTML 4.01 in favor of using styles to achieve similar or superior results.
size="n" or "+n|-n" |
Optional |
color="#rrggbb|colorname" |
Optional |
face="font[,font2][,font3]" (4.0) |
Optional |
SIZE specifies an absolute or relative font size. A relative font size is specified relative to either the default base font size (3) or base font size set previously using the BASEFONT tag.
COLOR sets the font color, either with a hexadecimal color code (#rrggbb) or a color name (black, white, aqua, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, and yellow). FACE specifies a font name or a comma-separated list of font names to be used in displaying nested text.
The FONT element should only be nested inside a block element (P, Hn, TD, and so on) and should never be nested directly inside the BODY element, for instance. Browsers may not care, but you'll get an error report if you try to validate the page as containing valid HTML 4.01 code.
Type: C,B |
Content: I,B |
Start/End: R/R |
FORM allows for the creation of user-input forms, with text boxes, check boxes, radio buttons, list menus, comment boxes, and so on.
ACTION specifies the URL of a forms processing agent, such as a CGI script, for instance. METHOD specifies the HTTP method used to submit form data. The GET method adds the submitted data to the end of the ACTION URL. The POST method includes the submitted data in the message body. The GET method is the default, but the POST method is generally used for posting data from user-input forms. There is also a limit to the number of characters that can be appended to a URL using the GET method (about 128 characters), thus limiting the amount of data that can be submitted using that method. ENCTYPE specifies the content type used to submit form data to the server; the default value is application/x-www-form-urlencoded.
Type: E,I |
Content: dna |
Start/End: dna |
INPUT is used to create input controls, including text boxes, check boxes, radio buttons, list menus, and so on.
type="control type" |
Required |
name="control name" |
Required[*] |
value="text" |
Optional[*] |
size="n" |
Optional[*] |
checked |
Optional |
disabled |
Optional |
readonly |
Optional |
maxlength="n" |
Optional |
src="url" |
Optional |
tabindex="n" |
Optional |
[*]NAME is not required with type="reset" or type="submit". VALUE is required with type="checkbox" and type="radio". SIZE is required with type="text". |
FIND IT ONLINE
TYPE identifies the input control being created, by specifying one of these values: text, checkbox, radio, submit, reset, image, button, hidden, password, and file. For fuller descriptions of the TYPE attribute values, and other attribute values that can be used with the INPUT element, see its section at the HTML 4.01 specification at www.w3.org/TR/html4/interact/forms.html#edef-INPUT.
Type: C,I |
Content: OPTGROUP,OPTION |
Start/End: R/R |
SELECT allows you to create a list menu of options that can be selected when the menu is expanded.
name="control name" |
Required |
size="n" |
Optional |
multiple |
Optional |
tabindex="n" |
Optional |
NAME specifies a list menu's name. SIZE specifies the number of rows in the list of options (1 is the default). MULTIPLE allows for multiple selections (by holding down the Ctrl or Shift key). TABINDEX can alter the position of the control in the document's tabbing order.
Type: C |
Content: Text |
Start/End: R/O |
OPTION is nested inside a SELECT element and specifies options to be displayed in a list menu.
value="option value" |
Optional |
label="option label" |
Optional |
selected |
Optional |
disabled |
Optional |
VALUE lets you specify an initial value for the option; when not stated, the option's value defaults to its content. SELECTED specifies that the option is initially selected. LABEL allows the specification of a shorter label for an option, that will be displayed in place of the OPTION element's content.
Type: C |
Content: OPTION |
Start/End: R/R |
OPTGROUP allows the organization of options in logical groups and can be helpful if a long list of options is being presented.
label="group label" |
Required |
disabled |
Optional |
The OPTGROUP element must be nested directly inside the SELECT element; you can't nest an OPTGROUP element inside of another OPT-GROUP element. Only the most recent browsers support this element.
Type: C,I |
Content: Text |
Start/End: R/R |
TEXTAREA creates a multi-line text box into which user comments can be input.
name="control name" |
Required |
cols="n" |
Optional |
rows="n" |
Optional |
tabindex="n" |
Optional |
NAME assigns a name to the control. COLS sets the width (in characters), and ROWS sets the height (in lines). TABINDEX can alter the position of the control in the document's tabbing order.
Type: C,I |
Content: I,B |
Start/End: R/R |
BUTTON can be used to create a submit button, reset button, or push button. An image can be displayed as the button by nesting it inside the BUTTON element.
name="control name" |
Required |
type="submit|reset|button" |
Required |
value="initial value" |
Required |
NAME assigns a name to the control. TYPE specifies whether a submit, reset, or push button is being created. VALUE specifies an initial value that is sent to the server. Text nested inside the BUTTON element is displayed as the button's label; an image nested inside the BUTTON element is displayed in place of the button.
Type: C,I |
Content: I |
Start/End: R/R |
LABEL associates a label with another control. The label is nested inside of the element.
for="ID value" |
Optional |
accesskey="character" |
Optional |
The value of FOR attribute must be the same as the value of the ID attribute of the control being labeled. When absent, the label is associated with the element's contents.
Type: C,B |
Content: I,B |
Start/End: R/R |
FIELDSET groups related controls (check boxes, radio buttons, and so on) in a set (a set of fields). The LEGEND element can be optionally nested inside of the FIELDSET element.
Type: C |
Content: I |
Start/End: R/R |
LEGEND allows the specification of a caption (or legend) for a fieldset.
Type: C |
Content: FRAME,NOFRAMES |
Start/End: R/R |
FRAMESET allows you to define a multi-frame Web page, where each frame contains and displays its own HTML document. Frames can be scrolled and resized by the user, unless scrolling and resizing is turned off.
rows="n,n,..." |
Optional |
cols="n,n,..." |
Optional |
ROWS specifies row dimensions in a FRAMESET element, whereas COLS specifies column dimensions. Pixel, percentage, or relative dimensions can be specified:
Pixel dimensions— You can define columns or rows within a FRAMESET element using absolute pixel dimensions. For instance, <FRAMESET ROWS="80,400"> defines two rows, with the top row being 80 pixels high and the bottom row being 400 pixels high. To allow for different screen resolutions (and browser window dimensions), you shouldn't set all rows or columns in a FRAMESET element as absolute pixels.
Percentage dimensions— You can define columns and rows as percentages of the total height or width of the browser window. For instance, <FRAMESET ROWS="80%,20%"> defines two rows, with the top row filling 80 percent and the bottom row filling 20 percent of the total height of the browser window.
Relative dimensions— You can combine either pixel or percentage row or column dimensions with the wildcard character (*). For instance, <FRAMESET ROWS="*,100"> defines the top row as a "relative" row that would expand or contract depending on the total space available in the browser window, whereas the bottom row would remain fixed at a height of 100 pixels.
A FRAMESET element can be nested inside of a FRAMESET element, replacing a FRAME element.
Type: E |
Content: dna |
Start/End: dna |
FRAME is nested inside the FRAMESET element; it defines a frame in a frameset and assigns characteristics to it.
src="url" |
Usually |
name="framename" |
Recommended |
frameborder="1|0" |
Optional |
marginheight="n" |
Optional |
marginwidth="n" |
Optional |
noresize |
Optional |
scrolling="yes|no|auto" |
Optional |
SRC specifies a framed document's URL. NAME names a frame so it can be targeted from hypertext links located in other frames. FRAMEBORDER turns the border of a frame off or on ("0" turns it off; "1" is the default). MARGIN-HEIGHT and MARGINWIDTH set the amount of left and right and top and bottom margin spaces, respectively (the minimum value is "2"). NORESIZE stops the manual resizing of a frame. SCROLLING determines how scroll bars are treated in a frame.
Type: C |
Content: I,B |
Start/End: R/R |
NOFRAMES provides content in a frame page that will be displayed by non-frames-capable browsers (or by frames-capable browsers where frames have been turned off). It should be nested inside the top-level FRAMESET tag. A non-frames-capable browser will ignore the FRAMESET element, whereas a frames-capable browser will ignore the contents of the NOFRAMES element.
Type: C,B |
Content: I |
Start/End: R/R |
The Hn elements, H1 through H6, allow you to define different heading levels in a page.
align="left|center|right|justify" (Deprecated) |
Optional |
ALIGN horizontally aligns a heading. Left alignment is the default.
Type: C |
Content: HEAD elements |
Start/End: O/O |
The HEAD element is nested inside of the HTML element and includes "header" information, such as the title, keywords for search engines, and other information.
profile="URL" |
Optional |
FIND IT ONLINE
PROFILE can be used to specify URLs of one or more meta data profiles, separated by white spaces. Current browsers or search engines do not support Meta data profiles. For more information on what meta data profiles are and how they might be used in the future, see www.w3.org/TR/html4/struct/global.html#profiles.
The TITLE, BASE, LINK, META, SCRIPT, and STYLE elements can all be nested inside the HEAD element. The OBJECT element can also be nested in the HEAD element but is more commonly nested in the BODY element.
Type: C,B |
Content: I |
Start/End: R/R |
TITLE is the only required element within the HEAD element. It identifies the title of the HTML document and is usually displayed by a browser in its top title bar. Many search engines also assign extra weight to the TITLE element's content when indexing a page.
Type: E |
Content: dna |
Start/End: dna |
BASE specifies the base URL for an HTML document. It is primarily used to indicate the original location of a moved document in order to preserve links using relative URLs.
href="url" |
Required |
target="frame name" (D) |
Optional |
The HREF value must be an absolute URL, not a relative URL. TARGET targets a name of a frame in which the linked document is to be displayed (see FRAMESET for more information).
Type: E |
Content: dna |
Start/End: dna |
LINK specifies the relation of the current document to other documents. Multiple LINK elements can be included to describe multiple relations. One of the most common uses of the LINK element is to link to an external style sheet.
ref="url" |
Optional |
rel="link types" |
Optional |
rev="link types" |
Optional |
media="media descriptors" |
Optional |
charset="character set" |
Optional |
hreflang="language code" |
Optional |
HREF specifies the linked document's URL. REL specifies the type of relationship of the current document to the linked document. No spaces are allowed in the REL value. REV specifies a reverse link (specifying a parent document, for instance). See www.w3.org/TR/html4/types.html#type-links for the list of recommended link types.
FIND IT ONLINE
Example:
<link rel="stylesheet" type="text/css" media="print">
Type: E |
Content: dna |
Start/End: dna |
META provides meta-data that further describes or characterizes the document and its properties.
name="text" |
See below |
http-equiv="refresh" |
See below |
content="text" |
Required |
NAME names the meta-information ("author," "date," "keywords," and so on). Many search engine robots recognize the "keywords" value as identifying a list of keywords. HTTP-EQUIV is mainly used to cause another document to load after a set interval, which can be handy if you've moved your page and want to switch visitors automatically from your old URL to your new one. CONTENT is required in combination with either NAME or HTTP-EQUIV.
Examples
For examples of using the META element to add descriptions and keyword lists to Web pages, see "Creating a META Description and Keyword List" in the Sunday Morning session. Here's an example of using the HTTP-EQUIV attribute to cause another page to load in a set interval of time (five seconds):
<meta http-equiv="refresh" content="5;url=http://www. myserver.com/mynewpage.html">
Note |
Some search engines will penalize a page that uses HTTP-EQUIV to forward visitors to another page, since it is a method that has often been used to inflate traffic for a page (by creating many "gateway" pages that all automatically forward visitors to the same page). The page that visitors are being forwarded to should not be penalized, howevezr. |
Type: C |
Content: Script |
Start/End: R/R |
SCRIPT allows the inclusion of client-side scripts, such as those created by JavaScript or VBScript. SCRIPT elements can be placed any number of times in the HEAD or BODY of an HTML document.
type="content type" |
Optional |
src="url" |
Optional |
TYPE specifies the type of script: "text/javascript," "text/vbscript," "text/tcl," and so on. SRC specifies the script location. In the absence of an SRC attribute, the script is assumed to be included inside the current SCRIPT element.
Script-aware browsers will ignore HTML comment tags that are placed above and below the content of the SCRIPT element. Browsers that are not scriptaware, on the other hand, will ignore anything included within the comment tags. Individual lines within a JavaScript script can be commented out by preceding it with two forward slashes (//).
Example:
<script type="text/javascript"> <!-- hide script from old browsers JavaScript code goes here... // end hiding script from old browsers --> </script>
Type: C |
Content: Style Sheet |
Start/End: R/R |
STYLE embeds a style sheet within an HTML document. Although Cascading Style Sheets (CSS1 and CSS2) is the primary style sheet language developed so far for use with HTML, other style sheet language implementations are possible.
type="MIME-type" |
Required |
media="media descriptor(s)" |
Optional |
title="advisory title" |
Optional |
FIND IT ONLINE
TYPE specifies the style sheet language ("text/css," for instance). MEDIA specifies the destination medium or media; it can specify a single media descriptor or a comma-separated list. Allowed media types include: screen, tty, tv, projection, handheld, print, braille, aural, and all. See www.w3.org/TR/html4/types.html#type-media-descriptors for descriptions of these media types. Future versions of HTML may introduce additional allowed media types.
TITLE specifies a title for the style sheet. It is also common to nest the contents of the STYLE element inside of a comment, to shield them from search engine robots or from browsers that don't support the STYLE element. For more information on using style sheets in HTML documents, see www.w3.org/Style/. The STYLE attribute, not to be confused with the STYLE element, can be used to apply inline styles to particular elements.
Type: E,B |
Content: dna |
Start/End: dna |
HR allows you to insert a horizontal rule.
size="n" (Deprecated) |
Optional |
width="n|n%" (Deprecated) |
Optional |
align="left|right|center" (Deprecated) |
Optional |
noshade (Deprecated) |
Optional |
SIZE specifies the height in pixels. WIDTH specifies the width, either in pixels or as a percentage. ALIGN aligns the rule (center alignment is the default). NOSHADE turns off any 3D shading. All these attributes are deprecated in favor of using styles to achieve similar or superior results.
Type: C,I |
Content: I,B |
Start/End: R/R |
I (Italic) displays text in italics. It is displayed in browsers exactly the same as the EM (Emphasis) tag, but is quicker to type.
Type: C,I |
Content: I,B |
Start/End: R/R |
IFRAME lets you insert and dimension an inline frame in a Web page. Versions of Netscape Navigator prior to Version 6 and versions of Internet Explorer prior to Version 3 do not support using inline frames.
src="url" |
Required |
height="n" |
Optional |
width="n" |
Optional |
name="frame name" |
Optional |
align="horizontal or vertical" |
Optional |
frameborder="1|0" |
Optional |
marginheight=""n|n%" |
Optional |
marginwidth="n|n%" |
Optional |
scrolling="yes|no|auto" |
Optional |
SRC gives the inline document URL. HEIGHT and WIDTH specify the dimensions. (The default in Internet Explorer is 300 pixels wide by 150 pixels high.) NAME assigns a name to the frame that can be targeted by an external link's TARGET attribute (see the FRAMESET element). FRAMEBORDER turns the border off ("0"). MARGINHEIGHT and MARGINWIDTH set the frame's margins. SCROLLING specifies how scrolling is handled for the frame. Text or block elements can be nested inside the IFRAME element to be displayed by browsers that do not support it.
Type: E,I |
Content: dna |
Start/End: dna |
IMG allows you to insert an inline image in your Web page.
src="url" |
Required |
alt="alternate text" |
Advised |
align="vertical and horizontal" |
Optional |
height="n" |
Advised |
width="n" |
Advised |
border="n" |
Optional |
hspace="n" |
Optional |
vspace="n" |
Optional |
usemap="#map name" |
Optional |
ismap |
Optional |
SRC specifies the URL for a GIF, JPEG, or PNG image. ALT provides alternative text for browsers that don't display images. ALIGN specifies vertical alignment ("top", "middle", or "bottom") relative to the baseline of the element, or it specifies horizontal alignment ("left" or "right") with text or other elements wrapping along the other side. The default is "bottom." HEIGHT and WIDTH specify the image dimensions. If the image is inside of an A (Anchor) element (an "image link"), the BORDER attribute can increase or decrease the width of the border around the image. Setting BORDER="0" will turn the border off. HSPACE and VSPACE add space to the left and right or above and below the image, respectively.
USEMAP specifies the name of a MAP element that defines the hotspots for a client-side image map. (See the MAP element.) ISMAP causes the clicked location in the image to be passed to the server, activating a server-side image map.
Type: C,I |
Content: I |
Start/End: R/R |
INS marks text as an insertion. How it is to be displayed is left up to the browser. Currently, only Internet Explorer 4.0 (or higher) displays this element (the attributes are not supported, however). For a description of the attributes that can be used with the INS element, see DEL.
Type: E,B |
Content: dna |
Start/End: dna |
ISINDEX creates a one-line user-input prompt. The W3C recommends that Web authors use the FORM and INPUT elements to create user-input prompts instead.
Type: C,I |
Content: I |
Start/End: R/R |
KBD displays text to be entered from the keyboard. The latest versions of both Internet Explorer and Netscape Navigator display it in a monospaced font, although some earlier versions of Internet Explorer also bold and reduce the size of this element. If all you want is monospaced text, your best bet is to use the TT tag instead.
Type: C,B |
Content: AREA,B |
Start/End: R/R |
MAP defines the hotspots in a client-side image map.
name="map name" |
Required |
NAME specifies the name of the MAP element that's called by an IMG element being used as an image map. The AREA element is nested in the MAP element.
Block elements (P, for instance) can be nested inside the MAP element, replacing the AREA element. These elements should contain links (A elements) that define the hotspot coordinates and target documents. This kind of image map, however, while more accessible and friendlier to search engines, is only supported by the most recent browsers.
Type: E |
Content: dna |
Start/End: dna |
AREA is an empty element that defines a hotspot within a MAP element.
shape="shape" |
Optional |
coords="coordinates" |
Optional |
href="url" |
Optional |
alt="alternate text" |
Recommended |
nohref |
Optional |
target="text" |
Optional |
tabindex="n" |
Optional |
SHAPE specifies the shape of the hotspot ("rect", "circle", or "poly"). The default is "rect" (rectangle). COORDS specifies the coordinates of a hotspot. If COORDS is absent, the image coordinates are used. HREF specifies the URL that's activated by the hotspot. If HREF is absent, the document URL is used. Use of ALT is strongly recommended to provide alternative text for browsers that don't display images. NOHREF specifies that the area has no action. TARGET targets a frame name (see the FRAMESET element). TABINDEX specifies the hotspot's tabbing order position. Here's an example:
Example:
<p align="center"><img src="../navbar.gif" border="0" width="450" height="75" usemap="#navbar"> <map name="navbar"> <area shape="rect" alt="Back" coords="59,10,141,65" href="../back.htm"> <area shape="rect" alt="Home" coords="180,10,268,66" href="../home.htm"> <area shape="rect" alt="Next" coords="307,9,390,66" href="../next.htm"> <area shape="default" nohref> </map>
Type: C,B |
Content: LI,B |
Start/End: R/R |
MENU creates a menu list. All browsers display this element identically to the UL element. It is also deprecated in HTML 4.01 in favor of using the UL element.
Type: C |
Content: B |
Start/End: R/R |
NOSCRIPT provides alternative text in case an otherwise script-aware browser is either not configured to execute scripts or does not support the specified scripting language. A browser that does not support running scripts will display the content of the element.
Type: C,B |
Content: I,B |
Start/End: R/R |
OBJECT provides a single source for inserting objects into an HTML document, including image, sound, video, animation, program (such as Java and ActiveX), HTML, and other files.
classid="URL" |
Optional |
codebase="URL" |
Optional |
codetype="content-type" |
Optional |
data="URL" |
Optional |
type="content-type" |
Optional |
standby="text" |
Optional |
id="object name" |
Optional |
FIND IT ONLINE
This element can be used in place of the IMG and APPLET elements, as well as the non-standard EMBED element (not part of HTML 4.01). For a full description of the OBJECT element and its attributes, see www.w3.org/TR/html40/struct/objects.html.
Type: E |
Content: dna |
Start/End: dna |
PARAM is an empty element (when nested inside the OBJECT element) that can be used to pass named parameters to an object.
name="parameter name" |
Required |
value="parameter value" |
Optional |
valuetype="data|ref|object" |
Optional |
type="MIME-type" |
Optional |
NAME specifies a name token, which must start with a letter (A to Z or a to z) and can be followed by any number of letters, digits, hyphens, or periods. Character entities cannot be included. VALUE contains the parameter value that's being passed to the object. VALUETYPE specifies the type of value being passed to the object. (The data is passed as a string, URL, or object, depending on whether valuetype="data", valuetype="ref", or valuetype="object" is set.) TYPE specifies the MIME-type (or content-type) of the passed value.
Example:
Type: C,B |
Content: LI,B |
Start/End: R/R |
OL creates a numbered list. OL elements can be nested inside each other to create a multilevel numbered list. OL elements can also be nested inside of UL (Unordered List) elements and vice versa.
type="1|a|A|i|I" (D) |
Optional |
start="n" (D) |
Optional |
compact (D) |
Optional |
TYPE specifies the type of ordered list. START specifies where the list is to start, other than at 1, a, A, i, or I (such as 2 or C, for instance). TYPE and START are deprecated in favor of using styles. COMPACT is intended to display a compact list; besides being deprecated, it is not supported by any current browsers and by very few older ones.
Type: C,B |
Content: I,B |
Start/End: R/O |
LI is used in combination with the UL element (and the OL element) to specify the items in a list. As generally used, the LI element is not an empty element, but a container element with an implied end tag. Adding the end tag currently has no effect, although HTML 4.0 has specified that adding the end tag should cause additional space to be added following a list item.
type="1|a|A|i|I" (D) |
Optional |
value="n" (D) |
Optional |
start="n" (D) |
Optional |
compact (D) |
Optional |
These attributes force a type and value for any list item, with ensuing list items conforming to the new type and number values. You could, for instance, create a list numbered 1, 2, 4, 5 (skipping past 3)—but why would you want to? TYPE, VALUE, and START are deprecated in this case in favor of using styles. COMPACT has never been widely supported by browsers and is also deprecated.
Type: C,B |
Content: I |
Start/End: R/O |
P (Paragraph) defines a text paragraph. The P element is a container element, although adding the end tag is considered optional.
align="left|center|right|justify" (D) |
Optional |
ALIGN specifies that the paragraph is either centered or right-aligned. Left alignment is the default. Leaving off the optional end tag can produce undesirable results in some browsers or when using styles.
Type: C,B |
Content: I,B |
Start/End: R/R |
PRE is used to include a block of text displayed in a monospaced font with all spaces and line breaks translated literally. Prior to the TABLE element, the PRE element was the only way to display tabular or columnar data or information. The IMG, OBJECT, BIG, SMALL, SUB, SUP, and FONT elements are not allowed within a PRE element. Because line breaks are translated literally, you don't need to use P or BR elements, but you should be aware that <p> and <br> codes will be parsed by a browser, rather than presented literally. Character entities can also be included in the PRE element.
Type: C,I |
Content: I |
Start/End: R/R |
Q (Quote) displays quoted text. Theoretically, browsers should be able to render this differently depending on the document's language. This is also supposed to be a "smart" element that desists from inserting quotation marks if they are already present. Currently, few browsers support this element. (Internet Explorer 6 does not support it.)
cite="url" |
Optional |
lang="language[-country] code" |
Optional |
dir="ltr|rtl" |
Optional |
FIND IT ONLINE
CITE provides a URL pointing to the source of the quote. LANG specifies the language of the quote, so appropriate quote marks can be rendered. For listings of two-character language and country codes, see www.unicode.org/unicode/onlinedat/languages.html and www.unicode.org/unicode/onlinedat/countries.html.
Type: C,I |
Content: I |
Start/End: R/R |
S (Strikethrough) renders text in strikeout. Originally a proposed HTML 3.0 element that didn't make it into HTML 3.2, the S element was included in HTML 4.0 (and deprecated at the same time in favor of the DEL element). If backward compatibility with older browsers is important, use STRIKE instead. See also STRIKE and DEL.
Type: C,I |
Content: I |
Start/End: R/R |
SAMP renders "sample" text or any other string of literal characters. All browsers render it identically to the TT tag, which should be used instead.
Type: C |
Content: Script |
Start/End: R/R |
SCRIPT can be inserted either in the HEAD or BODY element. For more information on the SCRIPT element, see its listing under the HEAD element.
Type: C,I |
Content: I |
Start/End: R/R |
SMALL reduces the font size by one size, relative to the base font size. It can be nested inside itself to reduce the font size down two levels (or more, if the base font size has been increased).
Type: C,I |
Content: I |
Start/End: R/R |
SPAN is similar to the DIV element, except that it's a text element instead of a block element. By itself, the SPAN element does absolutely nothing—only when you use it as a vehicle for applying styles to "spans" of text does it come to life (see the STYLE element).
Type: C,I |
Content: I |
Start/End: R/R |
STRIKE was originally a Netscape extension for marking strikeout text that was included in HTML 3.2 but has since been deprecated in HTML 4 in favor of the new DEL tag. All the same, the STRIKE tag is much more likely to be supported by older browsers than S or DEL.
Type: C,I |
Content: I |
Start/End: R/R |
STRONG is a logical element that specifies that nested text is strongly emphasized. It is normally displayed in a bold font, indistinguishable from the B element.
Type: C,I |
Content: I |
Start/End: R/R |
SUB causes nested text to be subscripted. Internet Explorer 3.0 and Navigator 4.0 display subscripts and superscripts in a smaller font, but earlier versions of these browsers do not.
Type: |
Content: |
Start/End: |
SUP marks text as superscripted. To allow for older non-supporting browsers, you might want to put superscripted (or subscripted) text inside of parentheses.
Example:
<p>Try Goober's Hair Grease<sup>(TM)</sup>!</p>
Type: C,B |
Content: Table Elements |
Start/End: R/R |
TABLE displays text or other objects in a tabular format (columns and rows). The following elements are nested directly inside the TABLE element: CAPTION, TR, THEAD (4.0), TBODY (4.0), and TFOOT (4.0).
align="left|center|right" (D) |
Optional |
width="n|n%" |
Optional |
border="n" |
Optional |
cellspacing="n" |
Optional |
cellpadding="n" |
Optional |
bgcolor="#rrggbb|colorname" (4.0) |
Optional |
cols="n" (4.0) |
Optional |
summary="text" (4.0) |
Optional |
frame="frame display" (4.0) |
Optional |
rules="rules display" (4.0) |
Optional |
ALIGN horizontally aligns the table to the left, center, or right. Left-alignment and right-alignment work similarly to the IMG tag, causing following text or other elements to flow around the table. WIDTH specifies the width of the table in pixels or as a percentage of a browser window. BORDER sets the thickness (in pixels) of the border around the table. CELLSPACING sets the space (in pixels) between cells. CELLPADDING sets the space (in pixels) within cells. VALIGN specifies whether text in a table is top or bottom aligned.
BGCOLOR assigns a background color. This works exactly the same as in the BODY element. COLS specifies the number of columns in a table. This is intended to assist browsers to start rendering a table prior to receiving all the data. FRAME specifies which parts of the frame surrounding a table will be visible. Allowed values are "void", "above", "below", "hsides", "vsides", "lhs" (left), "rhs" (right), "box", and "border". RULES specifies which rules within a table will be visible. Allowed values are "none", "groups" (between THEAD, TFOOT, TBODY, and COLGROUP), "rows", "cols", and "all". SUMMARY provides a summary of the table's purpose and structure that can be presented by speech or Braille browsers, for instance.
Type: C,B |
Content: I |
Start/End: R/R |
CAPTION specifies a caption for a table.
align="top|bottom|left|right" (D) |
Optional |
ALIGN aligns the caption relative to the top, bottom, left, or right of a table. The default is top. This attribute is deprecated in favor of using styles.
Type: C,B |
Content: TD,TH |
Start/End: R/O |
TR defines a row in a table. TD (Table Data) and TH (Table Heading) define the cells that compose a table row and are nested directly inside the TR element.
align="left|center|right|justify|char" |
Optional |
valign="top|middle|bottom|baseline" |
Optional |
char="character" (4.0) |
Optional |
charoff="n" (4.0) |
Optional |
ALIGN and VALIGN allow you to horizontally and vertically align the contents of a table row. The CHAR and CHAROFF attributes, as well as the "char" value for the ALIGN attribute, are not currently supported. Once browsers support this, you'll be able to display columns aligned on a decimal character, for instance. (You can fudge this simply by setting right alignment, as long as the number of decimal characters are the same.)
Type: C |
Content: I,B |
Start/End: R/O |
TD defines a data cell within a table.
FIND IT ONLINE
ALIGN, VALIGN, HEIGHT, WIDTH, and BGCOLOR all work as described previously. COLSPAN and ROWSPAN in the TR element allow you to create a cell that spans (encompasses) more than one column or row. COLSPAN and ROWSPAN can be used in the same cell (TH or TD). NOWRAP turns wrapping off. ABBR, AXIS, HEADERS, and SCOPE have no effect in current browsers. See www.w3.org/TR/html4/struct/tables.html#edef-TD for further details.
Type: C |
Content: I,B |
Start/End: R/O |
TH defines a heading cell within a table and is displayed by a browser in a bold, center-aligned font. The allowable attributes for the TH element are the same as for the TD element.
Type: C |
Content: COL |
Start/End: R/O |
COLGROUP defines column groups in a table to which styles can be applied.
span="n" |
Optional |
width="n|n%|0*" |
Optional |
align="left|center|right" |
Optional |
valign="top|middle|bottom" |
Optional |
SPAN specifies the number of columns in a group (the default is "1"). WIDTH specifies the width for each column in a group. This can be set in pixels, as a percentage of the table width, or by assigning a value of "0*", which specifies that the width of any column in the group should be the minimum necessary to display its contents. ALIGN and VALIGN work the same as in the TABLE element.
Type: E |
Content: dna |
Start/End: dna |
COL is nested inside the COLGROUP element and sets SPAN and WIDTH values for cells within a column group. The same attributes applicable to the COLGROUP element are used with the COL element.
Example:
<table> <colgroup> <col width="40"><col width="20"><col width="0*"> </colgroup> <tr><td>First Col</td><td>Second Col</td><td>Third Col</td></tr> Remaining table rows inserted here </table>
Type: C |
Content: TR |
Start/End: R/R |
THEAD defines a group of rows as a table head.
align="left|center|right|justify|char" |
Optional |
valign="top|middle|bottom|baseline" |
Optional |
Type: C |
Content: TR |
Start/End: O/O |
TBODY defines a group of rows as the table body. The TBODY element takes the same attribute values as the THEAD element.
Type: C |
Content: TR |
Start/End: R/R |
TFOOT defines a group of rows as the table foot. The TFOOT element takes the same attribute values as the THEAD and TBODY elements. This element is currently supported by Internet Explorer 4.0 or greater.
Type: C,I |
Content: I |
Start/End: R/R |
TT is often referred to as the "Typewriter Text" element. It is displayed in a smaller, monospaced font by all browsers and is the preferred element for rendering monospaced text.
Type: C,I |
Content: I |
Start/End: R/R |
U (Underline) marks text as underlined. Be aware that versions of Netscape Navigator 3.0 and earlier do not support this element. Generally, if you want to add emphasis to an HTML document, you should use the I or EM tags or the B or STRONG tags.
Type: C,B |
Content: LI,B |
Start/End: R/R |
UL creates a bulleted list. UL elements can be nested inside each other to create a multilevel bulleted list. UL elements can also be nested inside of OL (Ordered List) elements and vice versa.
type="disc|square|circle" (D) |
Optional |
TYPE specifies the type of bullet ("disc", "square", or "circle") to be used with the list. (The default is "disc".) It is deprecated in favor of using styles to achieve the same result.
LI is used in combination with the OL element (and the UL element) to specify the items in a list. The LI element, despite appearances, is not an empty element, but a container element with an implied end tag.
type="disc|square|circle" (Deprecated) |
Optional |
TYPE forces a bullet type for a list item and for ensuing list items. TYPE is deprecated in favor of using styles.