Copied successfully!
Introduction to <em>
tag
The <em>tag in HTML is used to emphasize text. This tag is a semantic element, meaning it conveys meaning and importance to the text it surrounds, not just visual styling. When a browser encounters the <em>tag, it typically renders the enclosed text in italics to visually indicate the emphasis. However, the primary purpose of the <em>tag is to denote stress or importance in the content, which can also be picked up by screen readers and assistive technologies, enhancing accessibility.
Key Features of the <em>
Tag
Semantic Emphasis: The <em>
tag adds semantic meaning to the text, indicating that it should be read with emphasis. This is particularly useful for screen readers, which may alter their tone to emphasize the text, aiding visually impaired users.
Default Styling: By default, the text inside an
<em>
tag is rendered in italics by most browsers. This default styling can be customized using CSS to match the design requirements of a website while retaining the semantic meaning.
Nesting of Emphasis: You can nest
<em>
tags within each other or use them alongside other emphasis-related tags, such as <strong>
. When nested, the inner <em>
tag typically indicates a higher level of emphasis or a different type of stress, such as a change in tone or context.
SEO Benefits: Proper use of semantic tags like
<em>
can benefit SEO. Search engines recognize the <em>
tag and may consider the emphasized content more important, potentially giving it more weight in search results.
Accessibility Considerations: The
<em>
tag helps improve web accessibility by providing meaningful emphasis that screen readers can interpret. This helps ensure that all users, regardless of ability, can fully understand the content. Copy to clipboard
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>title of <em> tag</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>Levoric Learn : <em> tag</h1>
</header>
<div class="container">
<h2>Introduction</h2>
<p>Welcome to our <em>modern</em> website example. We showcase how to use the <em><em></em> tag to add emphasis to key text elements.</p>
<h2>Usage of <em><em></em></h2>
<p>The <em><em></em> tag is designed to <span class="highlight">emphasize</span> text, usually rendering it in italics to make important information stand out. For instance, <em>highlighted</em> and <em>emphasized</em> terms are visually distinct with this tag.</p>
<h2>Highlighted Sections</h2>
<p>Below, we use the <em><em></em> tag in highlighted boxes to emphasize certain key terms:</p>
<div class="highlight">
<p>This example demonstrates <em>emphasis</em> with a modern, clean design.</p>
</div>
<div class="highlight">
<p>Another <em>example</em> showing how <em>emphasis</em> can enhance readability.</p>
</div>
</div>
</body>
</html>
Copy to clipboard
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background-color: #f4f6f9;
color: #333;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
flex-direction: column;
}
header {
text-align: center;
padding: 20px;
width: 100%;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
position: fixed;
top: 0;
left: 0;
z-index: 1000;
}
.container {
padding: 20px;
max-width: 900px;
width: 100%;
background: #ffffff;
border-radius: 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
margin-top: 80px; /* Offset for fixed header */
}
h1 {
font-size: 2.5rem;
margin: 0;
font-weight: 600;
}
h2 {
font-size: 1.75rem;
color: #007bff;
margin-bottom: 20px;
border-bottom: 2px solid #e9ecef;
padding-bottom: 10px;
}
p {
line-height: 1.8;
margin: 0 0 20px;
font-size: 1.1rem;
color: #495057;
}
.highlight {
background-color: #e9ecef;
padding: 10px;
border-left: 5px solid #007bff;
border-radius: 6px;
margin: 20px 0;
}
.highlight em {
font-style: italic;
color: #007bff;
font-weight: 600;
}
Global Attributes
Attributes | Description |
---|---|
accesskey | Specifies a shortcut key to activate or focus an element. |
autocapitalize | Controls whether and how text input is automatically capitalized. |
class | Specifies one or more class names for the element, allowing CSS styling and JavaScript manipulation. |
contenteditable | Specifies whether the content of an element is editable or not. |
contextmenu | Specifies a context menu for the element. |
dir | Defines the text direction. Possible values are "ltr" (left-to-right), "rtl" (right-to-left), and "auto". |
draggable | Specifies whether an element is draggable. Possible values are "true" or "false". |
enterkeyhint | Specifies the action label or icon to be shown for the enter key on virtual keyboards. |
hidden | Indicates that the element is not yet, or is no longer, relevant. The browser does not display elements that have the `hidden` attribute set. |
id | Specifies a unique identifier for the element. |
inputmode | Provides a hint to browsers for which virtual keyboard configuration to use when editing this element or its descendants. |
is | Allows you to specify the type of custom element. |
lang | Specifies the language of the element's content. |
nonce | A cryptographic nonce ("number used once") that can be used by Content Security Policy (CSP) to determine whether or not a given fetch will be allowed to proceed. |
part | Specifies the element’s part in the shadow DOM. |
slot | Assigns a slot in a shadow DOM shadow tree. |
spellcheck | Indicates whether the element is subject to spell checking. |
style | Provides inline CSS styling for the element. |
tabindex | Specifies the tab order of the element. |
title | Adds extra information about the element, displayed as a tooltip when hovering over the element. |
translate | Specifies whether the content of the element should be translated. Possible values are "yes" or "no". |
HTML Attributes | Global Attributes | Event Attributes |
---|---|---|
To view the full list | To view the full list | To view the full list |
elements | |||||
---|---|---|---|---|---|
<em> | Yes | Yes | Yes | Yes | Yes |
Improve Our Platform
Did you find what you were looking for?
Learn how to contribute.Last updated on by our contributors.
View this page on GitHub• Report an issue with this content