浅析HTML标签strong和em的区别

yibin 2015-02-09 建站源码 528

  浅析HTML标签strong和em的区别,可以从三个层次上来谈。

  首先看 HTML 4.01 中的说明:
  EM: Indicates emphasis.
  STRONG: Indicates stronger emphasis.

  em 表示强调,strong 表示更强烈的强调。言简意赅,表明了 em 和 strong 的命名来历。并且在浏览器中,em 默认用斜体表示,strong 用粗体表示。这是第一个层次上的区别。
  em is for local emphasis. You see? Local emphasis. If you would emphasize a word in speech, use em.
strong is for global highlighting. When somebody looks at your document, at a glance, certain words and phrases should jump out. These are the words and phrases that make up the gist of the content — the highlights.
  em 用来局部强调,strong 则是全局强调。从视觉上考虑,em 的强调是有顺序的,阅读到某处时,才会注意到。strong 的强调则是一种随意无顺序的,看见某文时,立刻就凸显出来的关键词句。斜体和粗体刚好满足了这两种视觉效果,因此也就成了 em 和 strong 的默认样式。
  感觉上面已经解释得很清楚了?我们再来看看第三个层次上的区别。HTML5 草案 中做了详尽解释:
  The em element represents stress emphasis of its contents. The placement of emphasis changes the meaning of the sentence.
  The strong element represents strong importance for its contents. Changing the importance of a piece of text with the strong element does not change the meaning of the sentence.
  em 表示内容的着重点(stress emphasis),strong 表示内容的重要性(strong importance),strong 不会改变所在句子的语意,em 则会改变所在句子的语义。并且举了一个非常好的例子:

示例代码 [www.dedecms.com]<p><em>Cats</em> are cute animals.</p>
  强调猫,讨论的是哪种动物聪明可爱。

示例代码 [www.dedecms.com]<p>Cats <em>are</em> cute animals.</p>
  强调是,讨论的是猫是不是聪明可爱。

示例代码 [www.dedecms.com]<p>Cats are <em>cute</em> animals.</p>
  强调聪明可爱,讨论的是猫究竟是聪明可爱呢还是愚蠢讨厌。

示例代码 [www.dedecms.com]<p><strong>Warning.</strong> This dungeon is dangerous.
<strong>Avoid the ducks.</strong> Take any gold you find.
<strong><strong>Do not take any of the diamonds</strong>,
they are explosive and <strong>will destroy anything within
ten meters.</strong></strong> You have been warned.</p>
  strong 表示的是重要性上的强调,不会引起句子意思的变化。最后注意 em 和 strong 都可以有多重,比如可以用两个 strong 来表示内容很重要。
  可以看出,第二个层次上所说的局部强调和全局强调是不够准确的。em 和 strong 区别的玄妙处,在 HTML5 草案里才得到淋漓尽致的阐释。推荐大家有时间的时候,仔细阅读 HTML5 草案。有很多元素的语义,都阐释得非常清楚,对于我们如何在最恰当的地方使用最恰当的标签,非常具有价值。
  em 是句意强调,加与不加会引起语义变化。
  strong 是重要性强调,和局部还是全局无关,局部强调用strong也可以,strong强调的是重要性,不会改变句意。
  

扫码添加微信

13013082126 扫描微信 建站咨询 优化咨询