Difference between <i> and <em> tag of HTML
Last Updated :
15 Oct, 2024
The <i> and <em> tags in HTML both style text as italic, but they serve different purposes. The <i> tag is used for visual styling without semantic meaning, while <em> conveys emphasis and adds semantic importance, improving accessibility and meaning in content.
Note: The <em> tag adds semantic emphasis, while <i> simply applies italic styling for offset text.
HTML <i> tag
The <i> tag in HTML is used to display text in italics. It is generally used for stylistic purposes, such as denoting a different mood, voice, or foreign word, without adding any semantic emphasis to the content.
Syntax
<i> Content... </i>
Example: In this example we use of the <i> tag, rendering text in italics. It highlights the word "italic" and the tag name "<i>" itself inside a paragraph for illustration.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Use of <i> Tag</title>
</head>
<body>
<p>This is an
<i>italic</i>
word using the
<i><i></i>
tag in HTML.
</p>
</body>
</html>
Output:
tag Example OutputHTML <em> tag
The <em> tag in HTML is used to emphasize text, typically displayed in italics. It conveys semantic meaning, indicating that the emphasized text is important, which can also aid accessibility tools like screen readers in highlighting key content.
Syntax
<em> Content... </em>
Example: In this example we use of the <em> tag, which emphasizes text. It highlights the word "important" and the tag name "<em>" itself within a paragraph for demonstration purposes.
HTML
<!DOCTYPE html>
<html>
<head>
<title>Use of <em> Tag</title>
</head>
<body>
<p>This is an
<em>important</em>
word using the
<em><em></em>
tag in HTML.
</p>
</body>
</html>
Output:
tag Example Output Difference between <i> and <em> tag of HTML
Feature | <i> | <em> |
---|
Syntax | font-style: italic; | font-style: italic; font-weight: bold; |
Semantic Role | Presentational | Semantic (Emphasis) |
Accessibility | Generally ignored by screen readers | Recognized by screen readers as emphasis |
Nested Usage | Can be nested inside <em> or vice versa | Nesting <em> within <i> or vice versa maintains emphasis |
Semantics | Not semantically specific, may not convey emphasis | Semantically specific for conveying emphasis in text |
Supported Browser:
- Google Chrome 1
- Edge 12
- Firefox 1
- Opera 15
- Safari 4
Similar Reads
Difference between <div> and <span> Tag in HTML In HTML, the <div> and <span> tags are used for structuring and styling content. <div> creates block-level containers for grouping elements, while <span> creates inline containers for styling specific portions of text or elements within a block-level container. Syntax: <di
3 min read
Difference between <nav> and <menu> tag in HTML5 "<nav>" Tag: The <nav> tag is used to specify navigation links either within the same document or any other document which means it provides link to contents which are either on same or different page/document. Example: html <!DOCTYPE html> <html> <body> <h1>The n
3 min read
What is the difference between <section> and <div> tags in HTML? In web development, both the <div> and <section> tags are commonly used to structure content. The <section> tag is semantic and indicates that the enclosed content relates to a specific theme or topic, making it more meaningful for search engines and accessibility tools. In contras
3 min read
Difference Between Strong and Bold tag in HTML In HTML, the <b> and <strong> tags both make text look bold, so they might seem 100% the same â but there's an important difference between them.This article go through the distinction between <b> and <strong> in HTML, exploring their semantic meaning, rendering, accessibilit
2 min read
What is the difference between <html lang="en'> and <html lang="en-US'> ? The lang attribute specifies which language is used to write the content of a web page. It is used to set the language for the whole text of the web page.The <html lang="en"> specifies the language of the document as English, while <html lang="en-US"> narrows it down to English as used i
2 min read