About This CSS Issue
The font-style CSS property controls whether text is displayed in a normal, italic, or oblique face from its font-family. It has a limited set of accepted values, and the W3C validator will flag any value that falls outside this set.
This error commonly occurs for a few reasons:
-
Confusing
font-stylewithfont-size: Since both properties start withfont-, it’s easy to accidentally typefont-style: 1.2emwhen you meantfont-size: 1.2em. Numeric and length values are not valid forfont-style. -
Confusing
font-stylewithfont-weight: Writingfont-style: boldis invalid becauseboldis afont-weightvalue, not afont-stylevalue. -
Typos in keyword values: Misspelling a valid keyword, such as
font-style: itallicorfont-style: oblque, will trigger this error. -
Using the
obliqueangle syntax incorrectly: Whileobliquecan accept an optional angle (e.g.,oblique 10deg), providing an angle without theobliquekeyword or using an invalid unit will cause a validation error.
Using invalid CSS values can lead to unpredictable rendering across browsers. Most browsers will ignore the entire declaration when they encounter an invalid value, meaning your intended styling won’t be applied at all. Keeping your CSS valid ensures consistent behavior and makes debugging easier.
Valid font-style values
The accepted values for font-style are:
-
normal— displays the normal face of the font family. -
italic— selects the italic face; falls back toobliqueif unavailable. -
oblique— selects the oblique face; optionally accepts an angle value (e.g.,oblique 10deg). The angle defaults to14degif omitted. -
Global CSS values:
inherit,initial,revert,revert-layer,unset.
Examples
Incorrect: size value applied to font-style
This is the most common mistake — using a length value that belongs on font-size:
<p style="font-style: 1.2em;">This text has an invalid font-style.</p>
Correct: use font-size for size values
<p style="font-size: 1.2em;">This text has a valid font size.</p>
Incorrect: using bold with font-style
<p style="font-style: bold;">This text has an invalid font-style.</p>
Correct: use font-weight for boldness
<p style="font-weight: bold;">This text is bold.</p>
Incorrect: misspelled keyword
<p style="font-style: itallic;">This text has a typo in font-style.</p>
Correct: properly spelled keyword
<p style="font-style: italic;">This text is italic.</p>
Correct: using oblique with an angle
<p style="font-style: oblique 12deg;">This text is oblique at 12 degrees.</p>
Quick reference for commonly confused properties
If you’re unsure which property to use, here’s a quick guide:
| You want to change… | Use this property | Example value |
|---|---|---|
| Italic or oblique text |
font-style |
italic, oblique |
| Text size |
font-size |
1.2em, 16px |
| Text boldness |
font-weight |
bold, 700 |
| Text decoration |
text-decoration |
underline, line-through |
Find issues like this automatically
Rocket Validator scans thousands of pages in seconds, detecting HTML issues across your entire site.