gpt4 book ai didi

css - 为什么会有粗体和斜体元素?

转载 作者:太空宇宙 更新时间:2023-11-04 14:13:35 25 4
gpt4 key购买 nike

据我了解,<strong><em>使用标签是因为它们传达语义。执行 <b><i>标签也有语义意义还是它们的作用纯粹是表象?我认为 CSS 应该用于呈现内容(例如通过使用 font-weight )那么为什么 HTML5 有粗体和斜体元素?

最佳答案

这些标签是在以前版本的 HTML 中创建的,但已在 html 5 中重新设计,具有额外的语义含义。

我要引用的一篇非常好的文章是:http://html5doctor.com/i-b-em-strong-element/

从该来源引用(但有@Alohci 指出的更正):

  • i — was italic, now for text in an “alternate voice”, such as transliterated foreign words, technical terms, and typographically italicized text (W3C:Markup, WHATWG)
  • b — was bold, now "representing a span of text to which attention is being drawn for utilitarian purposes without conveying any extra importance and with no implication of an alternate voice or mood, such as key words in a document abstract, product names in a review, actionable words in interactive text-driven software, or an article lede" - http://www.w3.org/International/questions/qa-b-and-i-tags
  • em — was emphasis, now for stress emphasis, i.e., something you’d pronounce differently (W3C:Markup, WHATWG)
  • strong — was for stronger emphasis, now for strong importance, basically the same thing (stronger emphasis or importance is now indicated by nesting) (W3C:Markup, WHATWG)

引用(来自 https://webmasters.stackexchange.com/questions/27693/should-i-still-use-the-b-tag):

The HTML5 specification redefines b and i elements to have some semantic function, rather than being purely presentational. However, the simple fact that the tag names are 'b' for bold and 'i' for italic means that people are likely to continue using them as a quick presentational fix.

另请注意(警告):

You should always bear in mind that the content of a b element may not always be bold, and that of an i element may not always be italic. The actual style is dependent on the CSS style definitions. You should also bear in mind that bold and italic may not be the preferred style for content in certain languages.

You should not use b and i tags if there is a more descriptive and relevant tag available. If you do use them, it is usually better to add class attributes that describe the intended meaning of the markup, so that you can distinguish one use from another.

引用资料:

关于css - 为什么会有粗体和斜体元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34571912/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com