HTML and CSS offer us the ability to italicize text. I’m talking about text like this. Let’s cover everything you’ll need to know.
What is italic text and why would you italicize text?
You italicize text most often to call attention to it. Literally to emphasize a word, so that someone reading the sentence will give that word or phrase some extra oomph, as you might intend as the writer. Or, it might be following a particular style guide, like italicizing the title of something, say a published article.
<em>
tag
Use the The “em” in <em>
literally stands for emphasis. Browsers will, by default, make italicize text that is wrapped in HTML <em>
tags.
<p>
That was a <em>wonderful</em> party, Bebe.
</p>
Imagine the sound of that sentence, where the reader is emphasizing that word giving the sentence a different feel that if they didn’t.
<i>
tag
Use the The <i>
element is to apply italics to text without implying emphasis. It’s to visually set some text apart from other text without implying that a reader is applying extra weight to those words. Perhaps something like:
<p><i>Miranda thought:</i> What an interesting metaphor on the global economy.</p>
<p><i>Chris thought:</i> Is that mustard?</p>
<i>
and <em>
?
What’s the difference between One more time:
<em>
is for emphasis<i>
is for italic text without the emphasis
If you’re tempted to use <i>
for the title of something, like:
<p>
The book
<!-- Not the end of the world, but... -->
<i>Mr. Penumbra's 24-Hour Bookstore</i>
is good.
</p>
<p>
The book
<!-- ...this is more semantically correct. -->
<cite>Mr. Penumbra's 24-Hour Bookstore</cite>
is good.
</p>
Fortunately browsers italicize content wrapped in <cite>
tags, just like <i>
does, so no further work is required there if you’re citing a work (e.g. Moby Dick) or a publication (e.g. The New York Times).
Use your own HTML class and CSS
If the goal is set text apart visually, then we don’t have to reach for the <i>
element. Spans have no semantic meaning and can be styled for visual emphasis:
<p>
Shoes are <span class="emphasis">on sale</span> this week!
</p>
.emphasis {
background: lightyellow;
font-style: italic;
}
The CSS property font-style
is the one you need for making text italic, which you can apply to any selector you like.
Watch out for “Faux Italic”
Not all fonts have italicized characters. Or, you might be in a situation where the italic version of the font isn’t loaded. In either case, the browser will try to fake it anyway, which almost always looks awful (or at least much worse than using an actual italic font).
Nothing is going to warn you about this — you kinda just need an eye for it. Here’s an example of the font Merriweather in faux italic:
Unicode italics
There are a zillion characters available in Unicode, including letters that have an italic vibe.
You might use this when you don’t have HTML control to do things like italics like, say, on Twitter when composing a tweet.
The accessibility of this is awful. It will reach each character individually, making it (presumably, to me) hard to understand the word. Be very careful when using this, if you e even use it all.
Italics in variable fonts
This is a bit of an advanced concept, but there are things called variable fonts. They offer customization right in the browser. So rather than a second font file for the bold version, they have information in them to bold themselves with that one file. But “bold” is just an example of what a variable font might offer. Not all of them necessarily do.
A variable font might have a “slant” or “italic” option and you could apply that look that way.
There it is, five different answers to the question of when to italicize text. Hopefully this also helps with the next logical question: Which method should I use?
On the subject of “Watch out for ‘Faux Italic’,” there is a
font-synthesis
property that allows authors to tell browsers not to do this.In a supporting browser, if you set
font-synthesis: none
, then if you make something italic (or bold) and the italic (or bold) font isn’t available, it will just ignore the style change and use the regular font.Only problem: Chromium doesn’t support
font-synthesis
yet! But still, using it can prevent wonky icon fonts or non-Latin text in Firefox & Safari — and maybe eventually Chrome will catch up.are you sure about this statement?
i think the meaning has subtly shifted in html5 as part of the larger movement to remove the style-only tags like , , etc..
If you know something not represented here, let me know.
Two things I do know:
<i>
tag makes text italic in all browsersIn the early days of HTML, the
<i>
element was introduced to make text italic, no matter the intention, but during HTML 4.01, the spec had decided to make the<i>
element obsolete because of the same reason you mentioned. Then in HTML 5 ,the spec had reintroduced the<i>
element but this time the spec also introduced the<em>
element, and like Chris stated in the article, the<i>
is to italize text but with no emphasis and the<em>
is for emphasis. The same story for<b>
and<strong>
.Yes, I believe you are correct:
So while
<i>
is not for emphasis, its does imply additional semantics, beyond it simply being italicised or not.Don’t forget, italic is the olde Italian way of hand writing.
Italics are the old way of writing / typesetting to save horizontal space.
Current accessibility requirements recommended never using italics to assist all readers in easily following your writing.
Do you have a source there? I’d be extremely surprised to find out it’s an accessibility requirement to never ever use italic text. But hey I’ve been surprised before.
There is a note in the WCAG about avoiding chunks of italicized text, but that’s about it.
Nice article Chris!
For the sake of a left-field method, you can also technically use transform: skewX between -4deg and -14deg (or between -6deg and -9deg for contemporary fonts).
Chris, you write “Here’s an example of the font Merriweather in faux italic”, but the css in the CodePen has a note “/*
This copy actually has the italics… */” and yes, the example shows up in italic. If the font-family were, say Helvetica, which doesn’t have an italic, the example would show a slanted version of Helvetica, which I think was intended. Slanted versions are traditionally known as “oblique.”
Chris, your readers might be interested to know that accessibility used to be a criterion that discouraged italics in newspapers and other publications. The accessibility in question, though, was that of the Linotype operator, who had to jump up and change the tray of molds that were used to create the letters, since italics and roman molds of the same font had separate trays. The Associated Press Style Guide still substitutes quote marks for italics because in the old days the Linotype was used by AP members. That style has persisted even though making text italic is relatively easy nowadays.