CSS font properties
Examples
Specify all font properties in one declaration:
p.ex1
{
font: 15px arial, sans-serif;
}
p.ex2
{
font: italic bold 12px / 30px Georgia, serif;
}
{
font: 15px arial, sans-serif;
}
p.ex2
{
font: italic bold 12px / 30px Georgia, serif;
}
try it"
In the bottom of this page for more examples.
Attribute definitions and instructions
font shorthand property sets all the font properties in one declaration.
Settable properties are (in order): "font-style font-variant font-weight font-size / line-height font-family"
The value of font-size and font-family is required. If the lack of other values, the default values will be inserted, if there is a default value of words.
Note: line - the space between the rows and row height properties.
Defaults: | not specified |
---|---|
inherit: | yes |
version: | CSS1 |
JavaScript syntax: | object .style.font = "italic small-capsbold 12px arial, sans-serif" |
Browser Support
Figures in the table represent the first browser to support the version number of the property.
属性 | |||||
---|---|---|---|---|---|
font | 1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
Font properties
value | description |
---|---|
font-style | Prescribed font style. See: font-style for possible values. |
font-variant | Chinese fonts specified. See: font-Variant of possible values. |
font-weight | Prescribed font weight. See: font-weight for possible values. |
font-size / line-height | Font size and line height regulations. See: font-size and line-height of possible values. |
font-family | Provisions of the font family. See: font-Family of possible values. |
caption | The title font is defined controls (such as buttons, drop-down lists, etc.) used. |
icon | Define the font to be used marked with an icon. |
menu | Definition is the drop-down list of fonts to use. |
message-box | Define the font used by the dialog box. |
small-caption | Small versions caption fonts. |
status-bar | Define the font to be used in the window status bar. |
More examples
Some other font property values
This example demonstrates some other font property values.
related articles
CSS tutorial: CSS the Font