CSS font-style Property

CSS font-style property sets the font style for text in HTML Element(s).

The syntax to specify a value for font-style property is

font-style: value;

The following table gives the possible values that could be set to font-style property.

Value Description Examples
normal A normal font style. [Default Value] font-style: normal;
italic Italic text style. font-style: italic;
oblique Oblique text style. font-style: oblique;
initial Sets font-style to default value. font-style: initial;
inherit Inherits font-style value from its parent element. font-style: inherit;

Examples

In the following examples, we set font style for the text using font-style property.

Italic Font Style

In the following example, we set the style of text to italic, using font-style property.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <style>
        #p1 {
            font-size: 25px;
            font-style: italic;
        }
    </style>
</head>
<body>
    <p id="p1">This is a paragraph.</p>
</body>
</html>

Oblique Font Style

In the following example, we set the style of text to italic, using font-style property.

Example

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <style>
        #p1 {
            font-size: 25px;
            font-style: oblique;
        }
    </style>
</head>
<body>
    <p id="p1">This is a paragraph.</p>
</body>
</html>

Conclusion

In this CSS Tutorial, we learned about font-style property, and how to use this property for HTML Elements, with examples.