两者都强调文本。 <em>
标签以斜体显示文本,而 <strong>
则使其加粗。这是唯一的区别吗?
是的,“强调”与“重点强调”的定义相对而言比较模糊。唯一的标准定义可能是“它被强调了,但更加重要!”。
个人认为<em>
用于普通强调,你会以不同的语气读出强调的单词,<strong>
则用于那些需要提取文本中关键词和短语,以帮助浏览文字的人们快速了解主题的内容。
这并非标准解释,但在默认的斜体/粗体样式下表达得很合理。不管你使用何种方式,请保持一致。
<strong>是一个标签,用于在句子或短语周围放置,以表示“这比周围的文本更重要”。
<em>通常用于表示句子中单词的重音。
例如:
尽管有些人可能会说没有,但元素之间确实存在一种语义上的差别。
为了清楚地区分强调重音和重要性,并提供更多示例,请参见HTML 5草案。
来自 WHATWG 的 HTML Living 标准规范:
The
em
elementThe
em
element represents stress emphasis of its contents.[...]
The placement of stress emphasis changes the meaning of the sentence. The element thus forms an integral part of the content. The precise way in which stress is used in this way depends on the language.
Example
These examples show how changing the stress emphasis changes the meaning. First, a general statement of fact, with no stress:
Cats are cute animals.
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>
Note
[...]
The
em
element [...] isn't intended to convey importance; for that purpose, thestrong
element is more appropriate.
[...]
The
strong
elementThe
strong
element represents strong importance, seriousness, or urgency for its contents. [...] In this example, thestrong
element is used to denote the part of the text that the user is intended to read first.
<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>
em
:表示强调。
strong
:表示更强烈的强调。
在用户辅助工具(NVDA)中的效果。
它也对搜索引擎优化有影响。
<div>Lorem <span class="bold">ipsum</span> <span class="italic">dolor</span></div>
。 - squidbe