CSS fontProperty
Example
Specifies all font properties in one declaration:
p.ex1
{
font:15px arial,sans-serif;
}
p.ex2
{
font:italic bold 12px/30px Georgia, serif;
}
Try it Yourself »
More examples at the bottom of this page.
Property definition and usage instructions
The font shorthand property sets all font properties in one declaration.
canSettingsofPropertyYes(pressSequence): "font-style font-variant font-weight font-size/line-height font-family"
The values of font-size and font-family are required. If other values are missing, default values will be inserted, if there are default values.
Note:The line-height property sets the space between lines.
| Default value: | not specified |
|---|---|
| Inherited: | yes |
| version: | CSS1 |
| JavaScript Syntax: | object.style.font="italic small-caps bold 12px arial,sans-serif" |
Browser Support
The numbers in the table indicate the first browser version number that supports the property.
| Property | |||||
|---|---|---|---|---|---|
| font | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Font Features
| Value | Description |
|---|---|
| font-style | Specifies the font style. See:font-stylePossible values in. |
| font-variant | Specifies font variants. See:font-variantPossible values in. |
| font-weight | Specifies font weight. See:font-weightPossible values in. |
| font-size/line-height | Specifies font size and line height. See:font-sizeandline-heightPossible values in. |
| font-family | Specifies the font family. See:font-familyPossible values in. |
| caption | Defines the font used by caption controls (such as buttons, drop-down lists, etc.). |
| icon | Defines the font used by icon labels. |
| menu | Defines the font used by dropdown lists. |
| message-box | Defines the font used by dialog boxes. |
| small-caption | Small version of the caption font. |
| status-bar | Defines the font used by window status bars. |
More Examples
Some other font property values
This example demonstrates some other font property values.
Related Articles
CSS Tutorial:CSS Font
other extensions