Back to Library
Region:
Switch to ID
Advanced freeCodeCamp • lecture-understanding-nuanced-semantic-elements
When Should You Use the Emphasis Element Over the Idiomatic Text Element?
Lesson Overview
The choice between the emphasis element (`<em>`) and the idiomatic text element (`<i>`) is based on **semantic meaning** rather than visual appearance. While both elements typically render text in ...
The choice between the emphasis element (<em>) and the idiomatic text element (<i>) is based on semantic meaning rather than visual appearance. While both elements typically render text in italics by default, they serve different purposes in your HTML structure.
The Emphasis Element (<em>)
Use <em> when you need to convey stress emphasis on a word or phrase.
- Purpose: It indicates that the text within the tag is important or should be stressed when read aloud (e.g., by a screen reader). It changes the meaning of the sentence.
- Example: “I really want to go to the park.” (The word “really” changes the tone and intent of the sentence).
- Key takeaway: Use this when the text requires vocal or semantic emphasis.
The Idiomatic Text Element (<i>)
Use <i> to represent text that is offset from the normal prose for an alternate tone or mood, but without the added weight of semantic importance.
- Purpose: It is used for text that is stylistically or contextually different from the surrounding text, but not necessarily “stressed” in meaning.
- Common Use Cases:
- Foreign language words or phrases.
- Technical terms or taxonomic designations (e.g., Homo sapiens).
- Fictional character thoughts.
- Icons (often used in modern web development to wrap icon font classes).
- Key takeaway: Use this when the text is distinct from the surrounding context but does not require special semantic emphasis.
Summary Table
| Element | Semantic Meaning | When to Use |
|---|---|---|
<em> | Stress/Importance | When you need to emphasize a word to change the meaning or intent of a sentence. |
<i> | Alternate Tone/Voice | When text is distinct (e.g., foreign words, titles, thoughts, technical terms) but does not require emphatic stress. |
Important Guidelines
- Avoid pure styling: Neither
<em>nor<i>should be used solely to make text italic. If your goal is purely aesthetic, use CSS (font-style: italic;) instead. - Accessibility: Screen readers will often place audible stress on
<em>content, whereas<i>content may simply be read as normal text. - Semantic HTML: Always prioritize elements that describe what the content is rather than how it looks.