<em>:强调元素

<em> HTML 元素标记具有重音强调的文本。<em> 元素可以嵌套,每一层嵌套都表示更大程度的强调。

¥The <em> HTML element marks text that has stress emphasis. The <em> element can be nested, with each level of nesting indicating a greater degree of emphasis.

Try it

属性

¥Attributes

该元素仅包含 全局属性

¥This element only includes the global attributes.

使用说明

¥Usage notes

<em> 元素适用于与周围文本相比具有强调重点的单词,通常仅限于句子中的一个或多个单词,并影响句子本身的含义。

¥The <em> element is for words that have a stressed emphasis compared to surrounding text, which is often limited to a word or words of a sentence and affects the meaning of the sentence itself.

通常该元素以斜体显示。但是,它不应该用于应用斜体样式;为此目的使用 CSS font-style 属性。使用 <cite> 元素标记作品的标题(书籍、戏剧、歌曲等)。使用 <i> 元素标记具有替代语气或语气的文本,这涵盖了斜体的许多常见情况,例如科学名称或其他语言中的单词。使用 <strong> 元素来标记比周围文本更重要的文本。

¥Typically this element is displayed in italic type. However, it should not be used to apply italic styling; use the CSS font-style property for that purpose. Use the <cite> element to mark the title of a work (book, play, song, etc.). Use the <i> element to mark text that is in an alternate tone or mood, which covers many common situations for italics such as scientific names or words in other languages. Use the <strong> element to mark text that has greater importance than surrounding text.

示例

<i> 与 <em>

¥\ vs. <em>

一些开发者可能会对多个元素看似如何产生相似的视觉结果感到困惑。<em><i> 是一个常见的示例,因为它们都将文本设为斜体。有什么不同?你应该使用哪个?

¥Some developers may be confused by how multiple elements seemingly produce similar visual results. <em> and <i> are a common example, since they both italicize text. What's the difference? Which should you use?

默认情况下,视觉结果是相同的。但语义不同。<em> 元素代表其内容的强调强调,而 <i> 元素代表与普通散文不同的文本,例如外来词,虚构人物的思想,或者当文本引用单词的定义而不代表其含义时 语义意义。(作品的标题,例如书名或电影名,应使用 <cite>。)

¥By default, the visual result is the same. However, the semantic meaning is different. The <em> element represents stress emphasis of its contents, while the <i> element represents text that is set off from the normal prose, such as a foreign word, fictional character thoughts, or when the text refers to the definition of a word instead of representing its semantic meaning. (The title of a work, such as the name of a book or movie, should use <cite>.)

这意味着使用正确的方法取决于具体情况。两者都不是纯粹的装饰目的,这就是 CSS 样式的目的。

¥This means the right one to use depends on the situation. Neither is for purely decorative purposes, that's what CSS styling is for.

<em> 的示例可以是:"就这么做吧!",或:"我们必须对此做点什么"。阅读文本的人或软件会使用语言重音以斜体字强调单词。

¥An example for <em> could be: "Just do it already!", or: "We had to do something about it". A person or software reading the text would pronounce the words in italics with an emphasis, using verbal stress.

<i> 的示例可以是:"玛丽女王号昨晚启航"。这里,没有对 "玛丽皇后号" 这个词进行额外的强调或重要性。它只是表明所讨论的对象不是一位名叫玛丽的女王,而是一艘名为玛丽女王的船。<i> 的另一个例子可能是:"the 这个词是一篇文章"。

¥An example for <i> could be: "The Queen Mary sailed last night". Here, there is no added emphasis or importance on the word "Queen Mary". It is merely indicated that the object in question is not a queen named Mary, but a ship named Queen Mary. Another example for <i> could be: "The word the is an article".

¥Examples

在此示例中,<em> 元素用于高亮两个成分列表之间隐式或显式的对比:

¥In this example, the <em> element is used to highlight an implicit or explicit contrast between two ingredient lists:

html
<p>
  Ice cream is made with milk, sweetener, and cream. Frozen custard, on the
  other hand, is made of milk, cream, sweetener, and <em>egg yolks</em>.
</p>

结果

¥Result

技术总结

¥Technical summary

内容类别 流量内容措辞内容,可触及的内容。
允许的内容 措辞内容.
标签遗漏 无,开始和结束标记都是强制性的。
允许的父级 任何接受 措辞内容 的元素。
隐式 ARIA 角色 emphasis
允许的 ARIA 角色 任何
DOM 接口 HTMLElement 从 Gecko 1.9.2 (Firefox 4) 开始,Firefox 为该元素实现了 HTMLSpanElement 接口。

规范

¥Specifications

If you're able to see this, something went wrong on this page.

浏览器兼容性

¥Browser compatibility

If you're able to see this, something went wrong on this page.

也可以看看

¥See also