font-size Attribute | fontSize Property

DHTML, HTML, & CSS

font-size Attribute | fontSize Property


Sets or retrieves the size of the font used for text in the object.

Syntax

HTML{ font-size: sSize }
Scriptingobject.style.fontSize [ = sSize ]

Possible Values

sSize String that specifies one of the following values:
absolute-sizeSet of keywords that indicate predefined font sizes. Possible keywords include [ xx-small | x-small | small | medium | large | x-large | xx-large ]. Named font sizes scale according to the user's font setting preferences.
relative-sizeSet of keywords that are interpreted as relative to the font size of the parent object. Possible values include [ larger | smaller ].
lengthFloating-point number, followed by an absolute units designator (cm, mm, in, pt, pc, or px) or a relative units designator (em or ex). For more information about the supported length units, see CSS Length Units.
percentageInteger, followed by a %. The value is a percentage of the parent object's font size. In Internet Explorer 3.0, the value is calculated as a percentage of the default font size.

The property is read/write with a default value of medium; the cascading style sheets (CSS) attribute is inherited.

Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see dynamic propertiesInternet Link.

Remarks

Negative values are not allowed. Font sizes using the proportional "em" measure are based on the font size of the parent object.

Possible length values specified in a relative measurement, using the height of the element's font (em) or the height of the letter "x" (ex), are supported in Internet Explorer 4.0 and later.

Example

The following examples use the font-size attribute and the fontSize property to change font characteristics.

This example sets the font size on several paragraphs using different size values.

Sample Code

<STYLE>
   BODY{font-size: 10pt }
   .P1 {font-size: 14pt }
   .P2 {font-size: 75% }
   .P3 {font-size: xx-large }
   .P4 {font-size: larger }
</STYLE>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

This example uses inline scripting to set the font size to 14pt when an onmouseover event occurs.

<DIV STYLE="font-size:12pt" onmouseover="this.style.fontSize='14pt'">
:
</DIV>

This feature requires Internet Explorer 4.0 or later. Click the icon below to install the latest version. Then reload this page to view the sample.
Microsoft Internet Explorer

Applies To

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
Version data is listed when the mouse hovers over a link, or the link has focus.
A, ADDRESS, APPLET, B, BIG, BLOCKQUOTE, BODY, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, currentStyle, custom, DD, DFN, DIR, DIV, DL, DT, EM, FIELDSET, FORM, Hn, HTML, I, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OL, P, PLAINTEXT, PRE, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP

See Also

font, CSS Length Units


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? write us!Internet Link

© 1999 microsoft corporation. all rights reserved. terms of useInternet Link.