font-styleInherit
This inherits property from its parent element.
Example: In this example, we have set the value of color as inherit that will be inheriting the color property from its parent element.
<!DOCTYPE html>
<html>
<head>
<title> CSS | font-style Property </title>
<style>
span {
color: blue;
font-size: 70px;
}
.extra span {
color: inherit;
}
</style>
</head>
<body>
<div>
<span>w3wiki</span>
</div>
<div class="extra"
style="color:green">
<span>w3wiki</span>
</div>
<div style="color:red">
<span>w3wiki</span>
</div>
</body>
</html>
Output:
CSS font-style Property
The CSS font-style property is used to style text in a normal, italic, or oblique face from its font-family. This property helps to assign importance and decorate specific text, enhancing the overall user experience. The font-style property is an essential tool in CSS for designing and styling text effectively.
Syntax:
font-style: normal|italic|oblique|initial|inherit;
Property values:
- normal: This is the default value for the font-style property, displaying normal font text.
- italic: Displays the text in italic.
- oblique: Specifies an angle for the slant of the text, displayed as oblique in the browser.
- initial: Sets the font to its default value.
- inherit: Inherits the current property value from its parent element.
We will discuss all the font-style properties through the examples. Let’s begin with the normal font-style property.