Html <strong> vs <em>?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1936864/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 01:38:14  来源:igfitidea点击:

<strong> vs <em>?

htmlxhtmlsemantics

提问by Jitendra Vyas

What is the difference? Both of them emphasize the text. The <em>tag shows text as italics, whereas <strong>makes text bold, is this the only difference?

有什么不同?两者都强调文本。该<em>标签显示的文字为楷体,而<strong>品牌文本加粗,这是唯一的区别?

回答by bobince

Yeah, the definition of what ‘strong emphasis' is compared to just ‘emphasis' is pretty woolly. The only standard definitionwould be “it's emphasised, but more!!”.

是的,将“强烈强调”与“强调”相比较的定义非常模糊。唯一的标准定义是“它被强调,但更多!!”。

Personally I use <em>for normal emphasis where you'd read the emphasised word in a different tone of voice, and <strong>for that thing where you take key words and phrasesto pick them out of the text to help people skimming the text pick out the subjects.

我个人使用<em>正常的重视,你会在不同的语音语调读强调字,并<strong>为在那里你拿那个东西关键词和短语来接他们出来的文字,以帮助人们略读课文挑选出的主题。

This isn't a standard interpretation, but it makes some sense and rendered appropriately by the default italic/bold styles. Whatever you do, be consistent.

这不是标准的解释,但它有一定的意义,并通过默认的斜体/粗体样式适当呈现。无论你做什么,都要保持一致

回答by Alohci

<strong> is a tag you'd put around a sentence or phrase to indicate that "this is more important than the surrounding text".

<strong> 是放在句子或短语周围的标记,以表明“这比周围的文本更重要”。

<em> is generally used to indicate the stress of a word within a sentence.

<em> 通常用于表示一个词在句子中的重音。

For example:

例如:

In spite of what some might say, there isa semantic difference between the elements.

尽管什么有人可能会说,有就是元素之间的语义差别。

For a clear distinction between stress emphasis and importance, and more examples, see the HTML 5 draft.

有关强调重点和重要性之间的明确区别以及更多示例,请参阅 HTML 5 草案

回答by Quentin

In HTML4:

在 HTML4 中:

EM indicates emphasis.

EM 表示强调。

STRONG: Indicates stronger emphasis.

STRONG:表示更强调。

http://www.w3.org/TR/html4/struct/text.html#h-9.2.1

http://www.w3.org/TR/html4/struct/text.html#h-9.2.1

回答by Michael Borgwardt

Note that the difference is going to change:

请注意,差异将发生变化

In HTML 4.01, the <strong>tag defined strong emphasized text, but in HTML 5 it defines important text.

在 HTML 4.01 中,<strong>标签定义了强强调的文本,但在 HTML 5 中,它定义了重要的文本。

Doesn't make the issue any clearer, does it?

没有让问题更清楚,是吗?

回答by alexrogers

From the WHATWG's Living standard HTML spec:

来自 WHATWG 的生活标准 HTML 规范

emrepresents stress emphasis of its contents:

em代表其内容的重音强调:

These examples show how changing the stress emphasis changes the meaning. First, a general statement of fact, with no stress:

<p>Cats are cute animals.</p> By emphasizing the first word, the statement implies that the kind of animal under discussion is in question (maybe someone is asserting that dogs are cute):

<p><em>Cats</em> are cute animals.</p> Moving the stress to the verb, one highlights that the truth of the entire sentence is in question (maybe someone is saying cats are not cute):

<p>Cats <em>are</em> cute animals.</p> By moving it to the adjective, the exact nature of the cats is reasserted (maybe someone suggested cats were mean animals):

<p>Cats are <em>cute</em> animals.</p> Similarly, if someone asserted that cats were vegetables, someone correcting this might emphasise the last word:

<p>Cats are cute <em>animals</em>.</p> By emphasizing the entire sentence, it becomes clear that the speaker is fighting hard to get the point across. This kind of stress emphasis also typically affects the punctuation, hence the exclamation mark here.

<p><em>Cats are cute animals!</em></p> Anger mixed with emphasizing the cuteness could lead to markup such as:

<p><em>Cats are <em>cute</em> animals!</em></p>
These examples show how changing the stress emphasis changes the meaning. First, a general statement of fact, with no stress:

<p>Cats are cute animals.</p> By emphasizing the first word, the statement implies that the kind of animal under discussion is in question (maybe someone is asserting that dogs are cute):

<p><em>Cats</em> are cute animals.</p> Moving the stress to the verb, one highlights that the truth of the entire sentence is in question (maybe someone is saying cats are not cute):

<p>Cats <em>are</em> cute animals.</p> By moving it to the adjective, the exact nature of the cats is reasserted (maybe someone suggested cats were mean animals):

<p>Cats are <em>cute</em> animals.</p> Similarly, if someone asserted that cats were vegetables, someone correcting this might emphasise the last word:

<p>Cats are cute <em>animals</em>.</p> By emphasizing the entire sentence, it becomes clear that the speaker is fighting hard to get the point across. This kind of stress emphasis also typically affects the punctuation, hence the exclamation mark here.

<p><em>Cats are cute animals!</em></p> Anger mixed with emphasizing the cuteness could lead to markup such as:

<p><em>Cats are <em>cute</em> animals!</em></p>

strongrepresents strong importance, seriousness, or urgency for its contents:

strong代表其内容非常重要、严肃或紧迫:

<p>Welcome to Remy, the reminder system.</p>
<p>Your tasks for today:</p>
<ul>
 <li><p><strong>Turn off the oven.</strong></p></li>
 <li><p>Put out the trash.</p></li>
 <li><p>Do the laundry.</p></li>
</ul>
<p>Welcome to Remy, the reminder system.</p>
<p>Your tasks for today:</p>
<ul>
 <li><p><strong>Turn off the oven.</strong></p></li>
 <li><p>Put out the trash.</p></li>
 <li><p>Do the laundry.</p></li>
</ul>

回答by Arman Hakim Sagar

em: Indicates emphasis.

em: 表示强调。

strong: Indicates stronger emphasis.

strong:表示更强调。

Its effect in user accessibility tool (NVDA).

它在用户可访问性工具 (NVDA) 中的作用。

Its also effect in SEO.

它在 SEO 中也有影响。

Reference: https://www.w3.org/TR/html4/struct/text.html#h-9.2.1

参考:https: //www.w3.org/TR/html4/struct/text.html#h-9.2.1