the CSS font attribute
Example
Specify all font properties in one declaration:
p
.ex1
{
font:
15
px
arial
,
sans-serif
;
}
p
.ex2
{
font:
italic
bold
12
px
/
30
px
Georgia
,
serif
;
}
Try it »
There are more examples at the bottom of this page.
Property definition and usage
The font shorthand property sets all font properties in one declaration.
The properties that can be set are (in order): "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 defaults exist.
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 that supports this 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-style Possible values. |
| font-variant | Specifies font variants. See:font-variant Possible values. |
| font-weight | Specifies the font weight. See:font-weight Possible values. |
| font-size/line-height | Specifies the font size and line height. See:font-size and line-height Possible values. |
| font-family | Specifies the font family. See:font-family Possible values. |
| 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 drop-down lists. |
| message-box | Defines the font used by dialog boxes. |
| small-caption | A smaller version of the caption font. |
| status-bar | Defines the font used by the window status bar. |
More examples
Some other font property values
This example demonstrates some other font property values.
Related Articles
CSS Tutorial: CSS Font