CSS - font-style



Font styles are used to change the appearance or style of text. The font-style property is used to specify the font style for the selected text.

Possible Values

  • normal: Default font style where the text is displayed normally, without any slant or obliqueness.

  • italic: Text appears in an italicized style, with a slight slant to the right.

  • oblique: Text appears similar to italic but with a more exaggerated slant or angularity.

  • oblique <angle>: An oblique text with an angle to specify the slantness of the text.

    • If no oblique font face available, the browser will slant the text by specified angle.

    • Valid values for angle are degree values between -90deg to 90deg inclusive.

    • If no angle specified, 14deg is set by the browser.

    • Positive angle value slants the text to the end of line.

    • Negative angle values slant the text towards the beginning.

    • Larger angle values are preferred.

Applies to

All the HTML elements

DOM Syntax

object.style.fontStyle = "italic";

CSS font-style - Basic Example

Here is an example:

<html>
<head>
<style>
   p {
      padding: 5px;
      border: 2px solid blue;
   }
</style>
</head>
<body>
   <h2>Font-style</h2>
   <p style = "font-style: normal;">
      The text will be normal.
   </p>
   <p style = "font-style: italic;">
      The text will be italic.
   </p>
   <p style = "font-style: oblique;">
      The text will be obligue.
   </p>
   <p style = "font-style: oblique 45deg;">
      The text will be obligue and slanted 45deg.
   </p>
</body>
</html>
Advertisements