Font style changes how text looks by making it normal, italic, or oblique. It helps make writing easier to read or more interesting.
Font style in CSS
Start learning this pattern below
Jump into concepts and practice - no test required
or
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Introduction
Syntax
CSS
selector {
font-style: normal | italic | oblique;
}normal means regular text with no slant.
italic is a slanted style that is often used for emphasis.
oblique is a slanted style similar to italic but less supported.
Examples
CSS
p {
font-style: normal;
}CSS
em {
font-style: italic;
}CSS
span.highlight { font-style: oblique; }
Sample Program
This page shows three paragraphs with different font styles: normal, italic, and oblique. You can see how the text slants differently.
CSS
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Font Style Example</title> <style> body { font-family: Arial, sans-serif; padding: 1rem; } p.normal { font-style: normal; } p.italic { font-style: italic; } p.oblique { font-style: oblique; } </style> </head> <body> <p class="normal">This text is normal style.</p> <p class="italic">This text is italic style.</p> <p class="oblique">This text is oblique style.</p> </body> </html>
Important Notes
Not all fonts support oblique style well; it may look similar to italic.
Use font-style to improve text meaning and design.
Summary
font-style changes text to normal, italic, or oblique.
Italic and oblique make text slanted for emphasis or style.
Use it to make your text clearer and more attractive.
Practice
1. What does the CSS property
font-style do to text?easy
Solution
Step 1: Understand the purpose of
Thefont-stylefont-styleproperty controls the style of the font, specifically whether it is normal, italic, or oblique.Step 2: Compare options with the property function
Only It changes the text to normal, italic, or oblique style. correctly describes changing text to normal, italic, or oblique styles.Final Answer:
It changes the text to normal, italic, or oblique style. -> Option AQuick Check:
font-style = normal, italic, oblique [OK]
Hint: Remember font-style changes slant, not color or size [OK]
Common Mistakes:
- Confusing font-style with color or size properties
- Thinking font-style changes alignment
- Mixing up font-style with font-weight
2. Which of the following is the correct CSS syntax to make text italic using
font-style?easy
Solution
Step 1: Identify valid values for
The valid values arefont-stylenormal,italic, andoblique.boldandunderlineare not valid forfont-style.Step 2: Match the correct syntax for italic
The correct syntax to make text italic isfont-style: italic;.Final Answer:
font-style: italic; -> Option DQuick Check:
font-style: italic; is correct [OK]
Hint: Italic style uses 'italic' keyword exactly [OK]
Common Mistakes:
- Using 'bold' or 'underline' with font-style
- Missing the colon or semicolon
- Confusing font-style with font-weight or text-decoration
3. What will be the visual result of this CSS code?
p { font-style: oblique; }medium
Solution
Step 1: Understand the effect of
Thefont-style: oblique;obliquestyle makes text slanted, similar to italic but usually less angled.Step 2: Compare options with expected visual output
Only The paragraph text will be slanted slightly to the right. describes the text slanting to the right, which matches the oblique style effect.Final Answer:
The paragraph text will be slanted slightly to the right. -> Option CQuick Check:
font-style: oblique; = slanted text [OK]
Hint: Oblique means slanted text, not bold or hidden [OK]
Common Mistakes:
- Confusing oblique with bold or underline
- Expecting no change in text style
- Thinking oblique hides text
4. Identify the error in this CSS snippet:
h1 { font-style: italic oblique; }medium
Solution
Step 1: Check allowed values for
Thefont-stylefont-styleproperty accepts only one value at a time:normal,italic, oroblique.Step 2: Analyze the given value
The valueitalic obliqueis two values combined, which is invalid syntax.Final Answer:
Multiple values are not allowed for font-style. -> Option AQuick Check:
font-style accepts single value only [OK]
Hint: font-style takes only one value like italic or oblique [OK]
Common Mistakes:
- Using multiple values separated by space
- Misspelling property name
- Omitting semicolon but still expecting valid CSS
5. You want to style a paragraph so that normal text is shown, but when hovered, the text becomes italic. Which CSS code correctly achieves this?
hard
Solution
Step 1: Set default font style to normal
The paragraph should start withfont-style: normal;to show normal text.Step 2: Change font style on hover to italic
Using the hover selector, setfont-style: italic;to make text italic when hovered.Step 3: Verify other options
Other options either reverse the effect (starting italic and changing to normal on hover), use invalid values likeboldforfont-style, or misusefont-weightfor italic effect.Final Answer:
p { font-style: normal; } p:hover { font-style: italic; } -> Option BQuick Check:
Hover changes font-style to italic [OK]
Hint: Use :hover with font-style: italic for hover effect [OK]
Common Mistakes:
- Using font-weight instead of font-style for italic
- Reversing normal and italic styles
- Using invalid values like 'bold' for font-style
