HTML <em> Element

Publish in HTML Tutorial el 23/05/2025 22:58

The <em> Element: Emphasizing Text in HTML

The <em> element is used to define emphasized text in HTML. By default, browsers typically render this as italic text, but it's important to understand that emphasis is semantic, while italics are purely presentational.

When you use <em>, you're telling browsers and assistive technologies that this text should be stressed or emphasized when read aloud. Screen readers will often change their tone or inflection for content wrapped in <em> tags.


Basic Syntax

Rendered result: This text will be emphasized


When to Use <em>

  • To indicate verbal stress in speech
  • To highlight important words in a sentence
  • When you want semantic emphasis rather than just visual styling


Examples of <em> in Action

Example 1: Basic Emphasis

This example shows simple text emphasis in a sentence.

Play Code


Example 2: Multiple Emphasis Points

Showing how to emphasize multiple parts of a sentence.

Play Code


Example 3: Nested with Other Elements

Demonstrating how <em> can be nested within other elements.

Play Code


Example 4: JavaScript Dynamic Emphasis

Using JavaScript to toggle emphasis on user interaction.

Play Code


Example 5: JavaScript Emphasis Based on Time

Automatically emphasizing text based on the time of day.

Play Code


Tips and Tricks

  • Don't overuse: Too much emphasized text loses its impact and can make content harder to read.
  • CSS styling: You can customize how emphasized text appears using CSS: em { font-style: italic; color: #d32f2f; }
  • Accessibility: Screen readers will interpret <em> differently from <i>, so choose the right one for your needs.
  • Nesting: You can nest <em> elements for stronger emphasis, though this is rarely needed.
  • SEO: While search engines understand semantic markup, don't expect <em> to significantly impact rankings.


Difference Between <em> and <i>

While both elements typically render as italic text, they serve different purposes:

Element Purpose Semantic Meaning
<em> Textual emphasis Changes the meaning of the sentence
<i> Alternative voice or mood No semantic emphasis (e.g., technical terms, thoughts)

Remember: <em> is for content that needs emphasis, while <i> is for content that should be set apart stylistically without semantic importance.

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...