Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Style fontSize Property

Style fontSize Property

Style Object Reference The Style object


Definition and Usage

The fontSize property sets or returns the font size of the text.

Syntax

Sets the fontSize property:

Object.style.fontSize="

value

|inherit"

Returns the fontSize property:

Object.style.fontSize

Value Description
xx-small
 x-small       

 small       

 medium       

 large       

 x-large       

 xx-large | 把字体的尺寸设置为不同的固定尺寸,从 xx-small 到 xx-large。 |

| smaller | Decreases the font size by one relative unit. | | larger | Increases the font size by one relative unit. | | length | Defines the font size using units such as px, cm, etc. | | % | Defines the font size as a percentage of the parent element's font size. | | inherit | The fontSize property value is inherited from the parent element. |


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the fontSize property.

**Note:** IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Changes the font size of the text:

Runoob Tutorial(runoob.com)

This is some text.


Try it »


Style Object Reference The Style object