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

HTML DOM Style font Property

Style font Property

Style Object Reference The Style object


Definition and Usage

The font property sets or returns up to six separate font properties in a shorthand form.

With this property, you can set/return:

The properties above can also be set with individual style properties. Using individual properties is strongly recommended for better control.

Syntax

Sets the font property:

Object.style.font="[

style variant weight size/lineHeight family

]

or

[

reserved word

]"

Returns the font property:

Object.style.font

**Tip:** The font property has no default value.

Value Description
style Sets the font style.
variant Sets whether the text is displayed in a small-caps font.
weight Sets the font weight.
size Sets the font size.
lineHeight Sets the distance between lines.
family Sets the font family.
caption Defines the font for controls (such as buttons, drop-down lists, etc.).
icon Defines the font used for icon captions.
menu Defines the font used in menus.
message-box Defines the font used in dialog boxes.
small-caption Defines the font used in small controls.
status-bar Defines the font used in the window status bar.
inherit The font property value is inherited from the parent element.

Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the font 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 of the text:

Runoob Tutorial(runoob.com)

This is some text.


Try it »


Style Object Reference The Style object