CSS
🎨 What is CSS font-style?
The font-style property is used to define the appearance and posture of text in CSS. It determines whether text is displayed normally, italicized, or slanted.
This property is commonly used to emphasize text, highlight quotations, style names, and create visual distinction between different types of content.
🚀 Basic Usage
p {
font-style: italic;
}
📌 This makes all paragraph text appear in an italic style.
📚 CSS font-style Values
1️⃣ normal
Displays text in its default upright style without any slant.
h1 {
font-style: normal;
}
- Default text appearance
- Most commonly used value
2️⃣ italic
Displays text using the font's actual italic design, creating a more elegant and emphasized appearance.
p {
font-style: italic;
}
📌 Commonly used for quotes, book titles, foreign words, and emphasized content.
3️⃣ oblique
Displays text with an artificial slant. It looks similar to italic but is generated by skewing the normal font.
p {
font-style: oblique;
}
- Creates a slanted appearance
- Not a true italic font style
4️⃣ initial & inherit
These values are useful when resetting styles or inheriting font styles from parent elements.
p {
font-style: inherit;
}
- initial → Resets to browser default.
- inherit → Uses the parent element value.
⚡ Real World Example
h1 {
font-style: normal;
}
em {
font-style: italic;
}
p.note {
font-style: oblique;
}
💡 Summary Table
| Value | Description |
|---|---|
| normal | Default upright text |
| italic | Uses the font's true italic design |
| oblique | Artificially slanted text |
| initial | Resets to default value |
| inherit | Uses parent value |
-
🧠 Summary
- font-style controls the posture of text.
- Common values are normal, italic, and oblique.
- It is useful for typography, emphasis, and readability.
