CSS CSS Tutorial CSS Advanced CSS Responsive Web Design(RWD) CSS Grid CSS Properties Sass Tutorial Sass Functions



font-style

CSS (Cascading Style Sheets) is a style sheet language used for describing the presentation of a document written in HTML (Hypertext Markup Language). CSS provides a wide range of properties to style the HTML elements. One of the important properties is font-style, which is used to define the style of the font in an HTML document.

The font-style property is used to specify whether the font should be italic, oblique, or normal. It is a shorthand property that combines the font-style, font-variant, and font-weight properties. The font-style property can be applied to any text element in an HTML document, including headings, paragraphs, and links.

Syntax

The syntax for the font-style property is as follows:

selector {
  font-style: normal|italic|oblique;
}

The selector can be any HTML element, class, or ID. The font-style property can take one of the following values:

  • normal: The font is displayed in the normal style.
  • italic: The font is displayed in the italic style.
  • oblique: The font is displayed in the oblique style.

Examples

Let's see some examples of how to use the font-style property in CSS:

Example 1: Normal Font Style

The following code sets the font-style property to normal:

<p style="font-style: normal;">This is a normal font style.</p>

The output of the above code will be:

This is a normal font style.

Example 2: Italic Font Style

The following code sets the font-style property to italic:

<p style="font-style: italic;">This is an italic font style.</p>

The output of the above code will be:

This is an italic font style.

Example 3: Oblique Font Style

The following code sets the font-style property to oblique:

<p style="font-style: oblique;">This is an oblique font style.</p>

The output of the above code will be:

This is an oblique font style.

Conclusion

The font-style property is an important property in CSS that is used to define the style of the font in an HTML document. It can be used to set the font to normal, italic, or oblique style. By using the font-style property, we can make our HTML document more visually appealing and attractive.

References

Activity