The font-style property is used to specify the style of the font within an element. It allows you to apply italic or oblique styles to text. The property accepts three main values: normal, italic, and oblique.

  • normal: This is the default value, indicating that the font is displayed in its normal style.
  • italic: This value applies an italicized style to the font. It is specifically designed italic font, if available. Otherwise, the browser may attempt to create an italic effect by slanting the regular font.
  • oblique: This value applies an oblique style to the font, which is a slanted version of the regular font. Unlike italic, the oblique value doesn’t have a dedicated italic design.

Here’s an example:

p {
  font-style: italic;

In this example, the font-style: italic; rule sets the text within <p> elements to be displayed in an italic style. This would apply the italicized version of the font, if available, or create a slanted effect otherwise.

The font-style property is a handy tool for adding emphasis or visual variations to text, allowing you to adjust the style of fonts to suit your design needs.

Related posts