The font-style CSS descriptor allows authors to specify font styles for the fonts specified in the @font-face rule.
For a particular font family, authors can download various font faces which correspond to the different styles of the same font family, and then use the font-style descriptor to explicitly specify the font face's style. The values for the CSS descriptor is same as that of its corresponding font property.
Syntax
font-style: normal;
font-style: italic;
font-style: oblique;
font-style: oblique 30deg;
font-style: oblique 30deg 50deg;
Values
normal- Selects the normal version of the font-family.
italic- Specifies that font-face is an italicized version of the normal font.
oblique- Specifies that the font-face is an artificially sloped version of the normal font.
obliquewith angle- Selects a font classified as
oblique, and additionally specifies an angle for the slant of the text. obliquewith angle range- Selects a font classified as
oblique, and additionally specifies a range of allowable angle for the slant of the text. Note that a range is only supported when thefont-styleisoblique; forfont-style: normaloritalic, no second value is allowed.
Formal definition
| Related at-rule | @font-face
|
| Initial value | normal
|
| Computed value | as specified |
Formal syntax
normal | italic | oblique <angle>{0,2}
Examples
Specifying an italic font style
As an example, consider the garamond font family, in its normal form, we get the following result:
@font-face {
font-family: garamond;
src: url('garamond.ttf');
}
[[File:../../../../../../media.prod.mdn.mozit.cloud/attachments/2016/01/16/12265/c2ce105a610305ab306ddd4aa4e13670/garamondunstyled.jpg|unstyled Garamond]]
The italicized version of this text uses the same glyphs present in the unstyled version, but they are artificially sloped by a few degrees.
[[File:../../../../../../media.prod.mdn.mozit.cloud/attachments/2016/01/16/12267/971507e6da4872a511db34f835ba6be8/garamondartificialstyle.jpg|artificially sloped garamond]]
On the other hand, if a true italicized version of the font family exists, we can include it in the src descriptor and specify the font style as italic, so that it is clear that the font is italicized. True italics use different glyphs and are a bit different from their upright counterparts, having some unique features and generally have a rounded and calligraphic quality. These fonts are specially created by font designers and are not artificially sloped.
@font-face {
font-family: garamond;
src: url('garamond-italic.ttf');
font-style: italic;
}
[[File:../../../../../../media.prod.mdn.mozit.cloud/attachments/2016/01/16/12269/de65461a1029759d06216411ddf6b7aa/garamonditalic.jpg|italic garamond]]
Specifications
| Specification | Status | Comment |
|---|---|---|
| CSS Fonts Module Level 4The definition of 'font-style' in that specification. | Working Draft | Adds oblique keyword with angle value |
| CSS Fonts Module Level 3The definition of 'font-style' in that specification. | Candidate Recommendation | Initial definition |
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
font-style
|
Chrome
Full support 4 |
Edge
Full support 12 |
Firefox
Full support 3.5 |
IE
Full support 4 |
Opera
Full support 10 |
Safari
Full support 3.1 |
WebView Android
Full support ≤37 |
Chrome Android
Full support 18 |
Firefox Android
Full support 4 |
Opera Android
Full support 10.1 |
Safari iOS
Full support 2 |
Samsung Internet Android
Full support 1.0 |
Legend
- Full support
- Full support
See also
font-displayfont-familyfont-stretchfont-weightfont-variantfont-feature-settingsfont-variation-settingssrcunicode-range
font-style by Mozilla Contributors is licensed under CC-BY-SA 2.5.