Sets or retrieves a value that indicates the font size used for text in the object. What's New for Microsoft® Internet Explorer 6
When you use the
!DOCTYPE declaration to specify standards-compliant mode, the default value for this property is
small, not
medium.
Syntax HTML |
{ font-size : sSize }
|
---|
Scripting | object.style.fontSize [ = sSize ] |
---|
Possible Values sSize | Variant that
specifies or receives one of the following values.absolute-size | Set of keywords that indicate predefined font sizes. Named font sizes scale according to the user's font setting preferences. Possible values include the following:
xx-small, x-small, small, medium, large, x-large, xx-large.
| relative-size | Set of keywords that are interpreted as relative to the font size of the parent object. Possible values include the following:
larger, smaller.
| length | Floating-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 the CSS Length Units Reference. | percentage | Integer, followed by a percent (%). 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
for all objects except the following, for which it is read-only:
currentStyle.
The property has 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 About Dynamic Properties.
Remarks As of Internet Explorer 6, when you use the !DOCTYPE declaration to specify standards-compliant mode, the default value for this property is small, not medium. 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.
Examples
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. <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 Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
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 Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample. Standards Information
This property is defined in
Cascading Style Sheets (CSS), Level 1 (CSS1) .
Applies To |
A,
ADDRESS,
APPLET,
B,
BIG,
BLOCKQUOTE,
BODY,
BUTTON,
CAPTION,
CENTER,
CITE,
CODE,
COL,
COLGROUP,
currentStyle,
CUSTOM,
DD,
defaults,
DFN,
DIR,
DIV,
DL,
DT,
EM,
FIELDSET,
FORM,
hn,
HTML,
I,
INPUT type=button,
INPUT type=file,
INPUT type=image,
INPUT type=password,
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 Reference
|