font-style

CSS font-style Property

The font-style property defines the font style for a text. The property has three values: normal, italic and oblique.

Oblique is a roman font that has been skewed 8-12 degrees. Italic is another value that is created by the type designer with specific characters particularly lowercase “a” for creating a calligraphic and a slanted version. Oblique is less supported by browsers. Oblique is less supported by browsers.

类目类目
Initial Valuenormal
Applies toAll elements. It also applies to ::first-letter and ::first-line.
InheritedYes.
AnimatableNo.
VersionCSS1
DOM Syntaxobject.style.fontStyle = “oblique”;

Syntax

Syntax

font-style: normal | italic | oblique | initial | inherit;

Example of the font-style property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      h3.normal {
        font-style: normal;
      }
    </style>
  </head>
  <body>
    <h2>Font-style property example</h2>
    <h3 class="normal">We wrote this text as italic.</h3>
    <p>Lorem ipsum, or lipsum as it is sometimes known, is dummy text used in laying out print, graphic or web designs. The passage is attributed to an unknown typesetter in the 15th century who is thought to have scrambled parts of Cicero's De Finibus Bonorum et Malorum for use in a type specimen book.</p>
  </body>
</html>

The difference between italic and oblique font-styles

The difference between italic and oblique font-styles

Italic is considered to be a cursive font-style in character, but the oblique is sloping versions of the standard face. However, there is a very small difference between these two font-styles. The example below will show the usage of both italic and oblique font-styles:

Example of the font-style property with the “italic” and “oblique” values:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p.italic {
        font-style: italic;
      }
      p.oblique {
        font-style: oblique;
      }
    </style>
  </head>
  <body>
    <h2>Font-style property example</h2>
    <p class="italic">We wrote this text as italic.</p>
    <p class="oblique">We wrote this text as oblique.</p>
  </body>
</html>

Example of the font-style property with all the values:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p.normal {
        font-style: normal;
      }
      p.italic {
        font-style: italic;
      }
      p.oblique {
        font-style: oblique;
      }
    </style>
  </head>
  <body>
    <h2>Font-style property example</h2>
    <p class="normal">We wrote this text as normal.</p>
    <p class="italic">We wrote this text as italic.</p>
    <p class="oblique">We wrote this text as oblique.</p>
  </body>
</html>

Values

Values

ValueDescriptionPlay it
normalMeans that text characters will be normal. This is the default value of this property.Play it »
italicThe text will be shown as italic.Play it »
obliqueThe text will be shown as oblique.Play it »
initialMakes the property use its default value.Play it »
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部