Question
What are the differences between the <b> and <strong> elements, and between the <i> and <em> elements in HTML/XHTML? When should each element be used?
Short Answer
By the end of this page, you will understand why <b> and <i> are used for stylistic distinction, while <strong> and <em> communicate meaning. You will also learn how these choices affect accessibility, browser styling, and maintainable HTML.
Concept
HTML elements can describe either meaning (semantics) or a stylistic distinction.
<strong>means the content has strong importance, seriousness, or urgency.<em>means the content should receive stress emphasis, which can change the meaning of a sentence.<b>draws attention to text without claiming that it is important. It is useful for a visually distinct label, keyword, or product name.<i>marks text that is conventionally presented in an alternate voice or mood, such as a foreign phrase, a technical term, a thought, or a taxonomic name.
Browsers usually render both <b> and <strong> in bold, and both <i> and <em> in italics. That default appearance does not make the elements equivalent: their meanings are different.
Semantic elements matter because assistive technologies, search tools, browser reader modes, and future maintainers can use the meaning in your HTML. CSS should control appearance; HTML should communicate what the text represents.
Mental Model
Think of HTML as adding labels to words in a document.
<strong>is like attaching a red Important label.<em>is like changing your spoken voice to stress a particular word.<b>is like using a highlighter so a reader notices a keyword.<i>is like writing a phrase in a different voice, such as a foreign expression or a character's private thought.
Although some labels may make text look similar on paper, they communicate different reasons for the distinction.
Syntax and Examples
Use semantic elements when the text has semantic meaning:
<p><strong>Warning:</strong> This action permanently deletes your account.</p>
<p>I said I wanted the report <em>today</em>, not tomorrow.</p>
strongmarks the warning label as important.emstressestoday; the emphasis helps distinguish it fromtomorrow.
Use <b> and <i> when text needs a conventional visual distinction but is not necessarily important or emphasized:
<p>Search results for: <b>wireless headphones</b></p>
<p>The Latin name is <i>Homo sapiens</i>.</p>
bmakes the matching search phrase stand out.iidentifies the scientific name as a conventional alternate voice.
Do not choose an element only because of its default font style. If you only need a visual design effect, use a neutral element and CSS:
<p><span class="brand-name">Acme</span> Cloud Storage</p>
.brand-name {
font-weight: 700;
font-style: italic;
}
Step by Step Execution
Consider this HTML:
<p>
<strong>Payment failed.</strong>
Please check your <em>card number</em>.
Error code: <b>E42</b>.
The term <i>nonce</i> means a value used once.
</p>
When the browser reads the markup:
- It creates a paragraph.
- It recognizes
<strong>as important content. Browsers normally displayPayment failed.in bold. - It recognizes
<em>as stressed emphasis. Browsers normally displaycard numberin italics. - It recognizes
<b>as text that should stand out stylistically. Browsers normally displayE42in bold, but it is not marked as an urgent warning. - It recognizes
<i>as an alternate voice or conventionally offset term. Browsers normally displaynoncein italics. - A screen reader or reading mode can use the semantic cues from
strongandem; the exact announcement behavior depends on the assistive technology and its settings.
The visible result may contain bold and italic text, but the underlying HTML explains why each phrase is distinct.
Real World Use Cases
Common uses for each element include:
-
<strong>- A destructive-action warning:
<strong>This cannot be undone.</strong> - An urgent security message.
- Important information within an error or status message.
- A destructive-action warning:
-
<em>- Clarifying which word changes the sentence meaning:
I meant <em>this</em> file. - Stress in instructional prose:
Do <em>not</em> share your API key. - Nested emphasis in editorial content.
- Clarifying which word changes the sentence meaning:
-
<b>- Highlighting matching words in search results.
- Visually distinguishing labels or key terms in a summary.
- Calling attention to a product name without implying urgency.
-
<i>- Foreign words:
The phrase <i>déjà vu</i> is French. - Taxonomic names:
<i>Felis catus</i>. - Technical terms or a character's thoughts, when that convention fits the content.
- Foreign words:
For titles of works, such as books and films, <cite> is usually a more specific semantic choice than <i>.
Real Codebase Usage
In production code, teams generally choose the most meaningful element first and let CSS define the visual design.
Error and validation messages
<p class="error-message">
<strong>Invalid email address.</strong>
Enter an address in the format name@example.com.
</p>
The error is important, so strong is appropriate. The .error-message class can control colors, spacing, and typography without changing meaning.
Search-result highlighting
<p>
Result: How to configure <b>environment variables</b> in Node.js
</p>
The bold text is a matched query term, not necessarily important content. This is a good use of b.
Emphasis in documentation
<p>
Run this command from the project root, <em>not</em> from the `src` directory.
</p>
The emphasis changes the instruction's meaning, making em suitable.
Styling without semantic meaning
<span class="status-pill status-pill--new">New</span>
If New is only a visual badge, a span plus CSS is often clearer than using b. If it is important status information, use meaningful text and appropriate surrounding structure; do not rely on bold text alone to communicate the status.
Common Mistakes
Using <b> when the message is important
<!-- Less meaningful -->
<p><b>Warning:</b> Your session is about to expire.</p>
Use strong if the word represents importance or urgency:
<p><strong>Warning:</strong> Your session is about to expire.</p>
Using <i> for emphasis
<!-- Incorrect semantic choice when stress is intended -->
<p>I need it <i>now</i>.</p>
Use em because stressing now changes the meaning:
<p>I need it <em>now</em>.</p>
Using semantic tags only to get bold or italic styling
<!-- The text is not necessarily important -->
<strong class="logo">Northwind</strong>
Prefer a neutral element if the purpose is purely visual:
<span class="logo">Northwind</span>
Assuming default styling is guaranteed
A CSS reset or design system can make strong non-bold and em non-italic. Their semantic meaning remains. Do not depend on default browser styling as your only way to communicate critical information.
Forgetting that color and font weight are not enough
Do not communicate an error only by making text red or bold. Include clear words such as Error, Required, or an explanatory message.
Invalid XHTML-style markup
In XHTML, elements must be properly nested and closed:
<!-- Invalid nesting -->
<strong><em>Important</strong></em>
<!-- Valid nesting -->
<strong><em>Important</em></strong>
Comparisons
| Element | Semantic meaning | Typical browser appearance | Good use case |
|---|---|---|---|
<strong> | Strong importance, seriousness, or urgency | Bold | A warning or important error text |
<b> | Stylistic attention without extra importance | Bold | A highlighted search term |
<em> | Stress emphasis that can affect meaning | Italic | Do <em>not</em> publish this. |
<i> | Alternate voice, mood, or convention | Italic | A foreign phrase or scientific name |
<span> | No semantic meaning by itself | No special style | Text styled entirely through CSS |
<em> versus <strong>
<em> adds verbal stress. <strong> communicates importance. They can be nested when both meanings apply:
<p><strong><em>Do not</em> restart the server during migration.</strong></p>
<b> versus CSS font-weight
Use <b> when the text should be stylistically distinct in the document's meaning, such as a keyword. Use CSS font-weight on a span when bold is purely a visual design decision.
Cheat Sheet
<!-- Important or urgent content -->
<strong>Important notice</strong>
<!-- Stress changes the meaning -->
<em>Do not</em> deploy yet.
<!-- Draw attention without importance -->
<b>matching search words</b>
<!-- Alternate voice or convention -->
<i>in vitro</i>
<!-- Purely visual styling -->
<span class="highlight">Label</span>
<strong>usually looks bold, but means important.<em>usually looks italic, but means stressed emphasis.<b>usually looks bold, but means stylistically distinct.<i>usually looks italic, but means alternate voice or convention.- Default rendering can be changed with CSS.
- Use properly nested opening and closing tags, especially in XHTML.
- Use CSS for appearance; choose HTML elements based on meaning.
FAQ
Is <strong> the same as <b> in HTML?
No. They often look the same by default, but <strong> communicates strong importance while <b> marks text as stylistically distinct without adding importance.
Is <em> the same as <i> in HTML?
No. <em> represents stress emphasis, while <i> represents an alternate voice, mood, or convention such as a foreign phrase or technical term.
Should I use <b> and <i> at all?
Yes, when their specific meanings fit. They are valid HTML elements and are not obsolete. Do not use them merely to obtain a font style.
Can CSS change how <strong> and <em> look?
Yes. CSS can change or remove their default bold and italic appearance. Their semantic meaning in the HTML remains.
Can I nest <strong> and <em>?
Yes. Nest them when text is both important and stressed. Ensure tags are correctly nested: <strong><em>text</em></strong>.
Should a book or movie title use <i>?
Use <cite> when marking the title of a creative work. CSS may then style it in italics if desired.
Are these elements different in XHTML?
Their meanings are the same. XHTML additionally requires well-formed markup, including correctly nested and closed tags.
Mini Project
Description
Create a short account-security notice that uses semantic text elements correctly. The notice should distinguish urgent content, stressed instructions, a highlighted technical code, and a technical term without relying on the same element for every visual style.
Goal
Build an accessible HTML notice that demonstrates appropriate uses of <strong>, <em>, <b>, and <i>.
Requirements
Include an urgent security warning marked with <strong>.
Keep learning
Related questions
Add a Favicon to a Static HTML Page
Learn how to add a favicon to static HTML pages, use correct paths and icon formats, and troubleshoot browser caching and local-file issues.
Allow Only Numeric Input (0-9) in HTML Input Using jQuery
Learn how to allow only digits 0-9 in an HTML input using jQuery, with examples, validation tips, common mistakes, and best practices.
Apply CSS !important with jQuery .css()
Learn why jQuery .css() cannot set !important and how to use CSSStyleDeclaration.setProperty() to apply inline important styles safely.