{"action":"opened","issue":{"url":"https://api.github.com/repos/onestark/onestark.github.io/issues/3","repository_url":"https://api.github.com/repos/onestark/onestark.github.io","labels_url":"https://api.github.com/repos/onestark/onestark.github.io/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/onestark/onestark.github.io/issues/3/comments","events_url":"https://api.github.com/repos/onestark/onestark.github.io/issues/3/events","html_url":"https://github.com/onestark/onestark.github.io/issues/3","id":165115275,"number":3,"title":"CSS：em 和 strong 的区别","user":{"login":"onestark","id":3352695,"avatar_url":"https://avatars.githubusercontent.com/u/3352695?v=3","gravatar_id":"","url":"https://api.github.com/users/onestark","html_url":"https://github.com/onestark","followers_url":"https://api.github.com/users/onestark/followers","following_url":"https://api.github.com/users/onestark/following{/other_user}","gists_url":"https://api.github.com/users/onestark/gists{/gist_id}","starred_url":"https://api.github.com/users/onestark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/onestark/subscriptions","organizations_url":"https://api.github.com/users/onestark/orgs","repos_url":"https://api.github.com/users/onestark/repos","events_url":"https://api.github.com/users/onestark/events{/privacy}","received_events_url":"https://api.github.com/users/onestark/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-07-12T15:55:01Z","updated_at":"2016-07-12T15:55:01Z","closed_at":null,"body":"## 表现\r\n*em* vs **strong**  \r\n\r\n在浏览器中，`<em>` 默认用斜体表示，`<strong>` 用粗体表示。从样式表现上，`<strong>` 更加突出，更容易吸引眼光。显然，这种视觉上的差异设计是有目的的。\r\n\r\n\r\n## 程度\r\n\r\n> EM: Indicates emphasis.\r\n> STRONG: Indicates stronger emphasis.\r\n\r\n在 [HTML 4.01 的说明][1] 中，em 表示强调，strong 表示更强烈的强调。从两者视觉样式上的特点来说，这种“程度上”的解释确实有道理。\r\n\r\n但把二者放在一大段落、一遍文章中时，读者第一眼肯定注意到的是粗体的 strong，而很难第一时间找到斜体不加粗的 em，因此往往是当读者读到某一处时，才会发现这种强调，与 strong 的这种不看内容但立刻就凸显出关键词句的强调相比，em 更偏向于用来局部强调，而strong 则是全局强调。\r\n\r\n因此，光从二者强调程度上的强弱已经不足以说明其区别。\r\n\r\n\r\n## 语意\r\n\r\n在 [HTML 5][2] 中，进一步规定了两者的区别：\r\n\r\n> The em element represents stress emphasis of its contents.\r\n> The strong element represents strong importance, seriousness, or urgency for its contents.\r\n\r\nMDN 中也将两者进行了对比，[Emphasis vs. Strong][3]：\r\n\r\n> While in HTML4, Strong simply indicated a stronger emphasis, in HTML5, the element is described as representing \"strong importance for its contents.\" This is an important distinction to make. While Emphasis is used to change the meaning of a sentence (\"I love carrots\" vs. \"I love carrots\"), Strong is used to give portions of a sentence added importance (e.g., \"Warning! This is very dangerous.\") Both Strong and Emphasis can be nested to increase the relative degree of importance or stress emphasis, respectively.\r\n\r\nem 和 strong 已经不可以再用 HTML4 中从强调的程度来简单区分差别了。\r\n\r\n- em 表示内容的着重点（stress emphasis），放置的位置会改变所在句子的含义。\r\n- strong 表示内容的重要性（strong importance），强调句子的重要性而不会改变所在句子的语意。\r\n\r\n\r\n## 例子\r\n\r\n注：下面的例子中，斜体为 em，粗体为 strong。\r\n\r\n*Cats* are cute animals.\r\n强调猫，讨论的是哪种动物聪明可爱。\r\n\r\nCats *are* cute animals.\r\n强调是，讨论的是猫是不是可爱。\r\n\r\nCats are *cute* animals.\r\n强调可爱，讨论的是猫究竟是可爱还是不可爱。\r\n\r\n\"**Warning!** This is **very dangerous***.\r\nstrong 表示的是重要性上的强调，不会引起句子意思的变化。\r\n\r\n```html\r\n<p><strong>Warning.</strong> This dungeon is dangerous.\r\n<strong>Avoid the ducks.</strong> Take any gold you find.\r\n<strong><strong>Do not take any of the diamonds</strong>,\r\nthey are explosive and <strong>will destroy anything within\r\nten meters.</strong></strong> You have been warned.</p>\r\n```\r\n\r\n注：em 和 strong 均可嵌套来增强其程度。\r\n\r\n\r\n## 参考\r\n\r\n- [W3C: Text](https://www.w3.org/TR/html4/struct/text.html#h-9.2.1)\r\n- [HTML Living Standard: The strong element](https://html.spec.whatwg.org/multipage/semantics.html#the-strong-element)\r\n- [MDN: &lt;strong&gt;](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong)\r\n- [stackoverflow: &lt;strong&gt; vs &lt;em&gt;?](http://stackoverflow.com/questions/1936864/strong-vs-em)\r\n- [蓝色理想：em 和 strong 的区别](http://www.blueidea.com/tech/web/2008/6342.asp)\r\n- [Emphasis in context versus overall highlighting](http://www.cs.tut.fi/~jkorpela/html/em.html)\r\n\r\n[1]: https://www.w3.org/TR/html4/struct/text.html#h-9.2.1\r\n[2]: https://html.spec.whatwg.org/multipage/semantics.html#the-strong-element\r\n[3]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/strong"}}
{"actor":{"display_login":"onestark"}}