docs.rodeo

MDN Web Docs mirror

font-style

{{CSSRef}} 

The font-style CSS property sets whether a font should be styled with a normal, italic, or oblique face from its {{cssxref("font-family")}} .

{{EmbedInteractiveExample("pages/css/font-style.html")}} 

Italic font faces are generally cursive in nature, usually using less horizontal space than their unstyled counterparts, while oblique faces are usually just sloped versions of the regular face. When the specified style is not available, both italic and oblique faces are simulated by artificially sloping the glyphs of the regular face (use {{cssxref("font-synthesis")}}  to control this behavior).

Syntax

font-style: normal;
font-style: italic;
font-style: oblique;
font-style: oblique 10deg;

/* Global values */
font-style: inherit;
font-style: initial;
font-style: revert;
font-style: revert-layer;
font-style: unset;

The font-style property is specified as a single keyword chosen from the list of values below, which can optionally include an angle if the keyword is oblique.

Values

Variable fonts

Variable fonts can offer a fine control over the degree to which an oblique face is slanted. You can select this using the <angle> modifier for the oblique keyword.

For TrueType or OpenType variable fonts, the "slnt" variation is used to implement varying slant angles for oblique, and the "ital" variation with a value of 1 is used to implement italic values. See {{cssxref("font-variation-settings")}} .

Click “Play” in the code blocks below to edit the example in the MDN Playground. Change the angle value to see the slant of the text change.

<p class="sample">
  ...it would not be wonderful to meet a Megalosaurus, forty feet long or so,
  waddling like an elephantine lizard up Holborn Hill.
</p>
@font-face {
  src: url("https://mdn.github.io/shared-assets/fonts/variable-fonts/AmstelvarAlpha-VF.ttf");
  font-family: "AmstelvarAlpha";
  font-style: normal;
}

.sample {
  font:
    2rem "AmstelvarAlpha",
    sans-serif;
  /*font-variation-settings: "slnt" 12;*/
  font-style: oblique 23deg;
}

{{EmbedLiveSample("oblique-example", "", "200px")}} 

Accessibility

Large sections of text set with a font-style value of italic may be difficult for people with cognitive concerns such as Dyslexia to read.

Formal definition

{{cssinfo}} 

Formal syntax

{{csssyntax}} 

Examples

Font styles

<p class="normal">This paragraph is normal.</p>
<p class="italic">This paragraph is italic.</p>
<p class="oblique">This paragraph is oblique.</p>
.normal {
  font-style: normal;
}

.italic {
  font-style: italic;
}

.oblique {
  font-style: oblique;
}

{{ EmbedLiveSample('Font_styles') }} 

Specifications

{{Specifications}} 

Browser compatibility

{{Compat}} 

See also

In this article

View on MDN