NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<font> (Font Definition)

This element allows specification of the size, color, and font of the text it encloses.

Standard Syntax (Transitional Only)

class="class name(s)"
color="color name | #RRGGBB"
dir="ltr | rtl"
face="font name"
id="unique alphanumeric identifier"
lang="language code"
size="1 to 7 | +1 to +6 | -1 to -6"
style="style information"
title="advisory text">


Attributes Defined by Internet Explorer

accesskey="key" (5.5)
contenteditable="false | true | inherit" (5.5)
disabled="false | true" (5.5)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
tabindex="number" (5.5)
unselectable="on | off"(5.5)

Attributes Defined by Netscape

point-size="point size for font" (4)
weight="100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900" (4)

Events Defined by Internet Explorer

onactivate, onbeforeactivate, onbeforecopy, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, onclick, oncontextmenu, oncontrolselect, oncopy, oncut, ondeactivate, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onfocus, onfocusin, onfocusout, onhelp, onkeydown, onkeypress, onkeyup, onlosecapture, onmousedown, onmouseenter, onmouseleave, onmouseout, onmouseover, onmouseup, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresizeend, onresizestart, onselectstart, ontimeerror

Element Specific Attributes

This attribute sets the text color using either a browser-dependent named color or a color specified in the hexadecimal #RRGGBB format.

This attribute contains a list of one or more font names separated by commas. The user agent looks through the specified font names and renders the text in the first font that is supported.

This Netscape 4-specific attribute specifies the point size of text and is used with downloadable fonts.

This attribute specifies the font size as either a numeric or relative value. Numeric values range from 1 to 7 with 1 being the smallest and 3 the default. The relative values, + and -, increment or decrement the font size relative to the current size. The value for increment or decrement should range only from +1 to + 6 or -1 to -6.

Under Netscape 4, this attribute specifies the weight of the font, with a value of 100 being lightest and 900 being heaviest.


<font color="#FF0000" face="Helvetica, Times Roman" size="+1">
Relatively large red text in Helvetica or Times.


HTML 3.2, 4, 4.01 (transitional), XHTML 1.0 (transitional)
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 1.1, 2, 3, 4, 4.5-4.8, 6, 7
Opera 4-7


Use of this element is not encouraged, as it is not part of strict HTML and XHTML specifications. Style sheets provide a cleaner way of providing the same functionality when they are supported.

Interestingly, the transitional specification for some reason does not define core events for this element. In practice, they are supported by major browsers.

The default text size for a document can be set using the size attribute of the basefont element.

The HTML 3.2 specification supports only the color and size attributes for this element.

(X)HTML Elements
CSS Properties
Previous: fieldset Next: form
< Home | About | Chapters | Examples | Errata | Reference | Site Map >