style.fontSize (Property)

Controls the size of the text drawn with the current font. Note that different browser-support a text-imaging model at varying resolutions, and it is difficult to obtain consistent results when older browsers are used.


CSS level - 1
DOM level - 2
JavaScript - 1.5
JScript - 3.0
Internet Explorer - 4.0
Netscape - 6.0
Property/method value type:String primitive
JavaScript syntax:-myStyle.fontSize
CSS syntax:font-size: aSize
Argument list:aSizeA font size

Font sizes can be specified in a variety of measurement units.

There are some issues to do with font sizes that make fonts very difficult to control across platforms. This is affected by several factors:

There are differences between the way that fonts are rendered. Considering that the Macintosh supports at least three simultaneous font rendering models at a time and historically there have been several radically different font management schemes, it is amazing that fonts ever appear in the way they were intended. The Windows platform must provide at least half as many again, while the X-Windows support on the Linux platform supports a completely different font rendering model.

Certain font families appear to render larger than others for the same point size. This difference is due to the different x-height for the characters.

The differences between the Macintosh and the Windows environment are due to the 72 DPI vs. 96 DPI default pixel resolution of the screen displays. The latest versions of MSIE for the Macintosh provide a 96 DPI switch to work round this.

The symbolic names for font sizes do not render identically across platforms nor do they render the same across browsers within the same platform. These are the symbolic font size names for absolute sizes:

You can use numeric values with suffixes to indicate the units of measure:

The px suffix means pixels while the em value means the width of an em-dash in the current font. You can use floating point values for measurements in em units. You can also use floating point values for percentage values. The percentage relates to the containing parent object's font settings.

Two additional symbolic names are reserved for relative font sizes:

The larger and smaller keywords index up and down the scale defined by the absolute size keywords.


See also:JSSTag.fontSize, String.big(), String.fontsize(), String.small(), String.sub(), String.sup(), style.font