HTML & CSS Interview Question #13

What is the difference between <strong> and <b>, and between <em> and <i>?

HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner

Quick Interview Answer

strong indicates strong importance, seriousness, or urgency, while b draws attention without adding that importance. Similarly, em represents stress emphasis, while i represents text in an alternate voice or convention where italics are typically appropriate.

Detailed Explanation

strong indicates strong importance, seriousness, or urgency, while b draws attention without adding that importance. Similarly, em represents stress emphasis, while i represents text in an alternate voice or convention where italics are typically appropriate.

Browsers often render these pairs similarly by default, but their semantics differ. Choose elements based on meaning and use CSS when the requirement is purely visual styling.

Code Example

<p>
    <strong>Warning:</strong> Do not expose API keys.
</p>

<p>
    You <em>must</em> validate user input.
</p>

<p>
    Product name: <b>AS-Mart Pro</b>
</p>