Properties
CSS
font
The font property is a shorthand property for setting font-style, font-variant, font-weight, font-size, line-height, and font-family.
font: [[ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
| Initial: | normal, normal, normal, medium, normal, depends on user agent |
| Applies To: | all elements |
| Inherited: | yes |
| Percentages: | NA, except font-size refers to parent element's font size and line-height refers to the font size of the element itself |
| Media: | visual |
- Values
- DOM
- Example | Values | caption
- Example | Values | font-family | family-name
- Example | Values | font-family | generic-family
- Example | Values | font-size | absolute-size
- Example | Values | font-size | length
- Example | Values | font-size | percentage
- Example | Values | font-size | relative-size
- Example | Values | font-style | italic
- Example | Values | font-style | normal
- Example | Values | font-style | oblique
- Example | Values | font-variant | normal
- Example | Values | font-variant | small-caps
- Example | Values | font-weight | 100-900
- Example | Values | font-weight | bold
- Example | Values | font-weight | bolder
- Example | Values | font-weight | lighter
- Example | Values | font-weight | normal
- Example | Values | icon
- Example | Values | line-height | length
- Example | Values | line-height | normal
- Example | Values | line-height | number
- Example | Values | line-height | percentage
- Example | Values | menu
- Example | Values | message-box
- Example | Values | small-caption
- Example | Values | status-bar
- Example | DOM
- References
Values
font: value;
| Value: | Description: |
| absolute-size | Index to a table of font sizes: xx-small | x-small | small | medium | large | x-large | xx-large |
| bold | 700 in the ordered sequence |
| bolder | Bolder relative to the weight inherited from the parent |
| caption | Font used for captioned controls (buttons, drop-downs, ...) |
| family-name | Name of a font family of choice |
| generic-family | Name of a generic font family as an alternative |
| icon | Font used to label icons |
| inherit | Takes the same computed value as the property for the element's parent |
| italic | Cursive font which is slanted to the right |
| length | Horizontal or vertical measurements: em | ex | px | in | cm | mm | pt | pc |
| lighter | Lighter relative to the weight inherited from the parent |
| menu | Font used in menus (dropdown menus and menu lists) |
| message-box | Font used in dialog boxes |
| normal | Upright font |
| normal | 400 in the ordered sequence |
| normal | Not a small-caps font |
| normal | "Reasonable" value based on the font of the element |
| number | Number multiplied by the element's font-size |
| oblique | Normal font which is slanted to the right |
| percentage | Value relative to the inital value |
| percentage | Percentage multiplied by the element's font-size |
| relative-size | Relative to the table of font sizes and the font size of the parent element: smaller | larger |
| small-caps | Lower case letters look similar to the uppercase ones, but in a smaller size and with slightly different proportions |
| small-caption | Font used for labeling small controls |
| status-bar | Font used in window status bars |
DOM
[window.]document.getElementById("element-id").style.font = "font";
