<b>:引起注意元素

<b> HTML 元素用于引起读者对元素内容的注意,否则这些内容不会被赋予特别重要性。这以前称为 Boldface 元素,大多数浏览器仍然以粗体绘制文本。但是,你不应该使用 <b> 来设置文本样式或赋予重要性。如果你希望创建粗体文本,则应使用 CSS font-weight 属性。如果你希望表明某个元素特别重要,则应使用 <strong> 元素。

¥The <b> HTML element is used to draw the reader's attention to the element's contents, which are not otherwise granted special importance. This was formerly known as the Boldface element, and most browsers still draw the text in boldface. However, you should not use <b> for styling text or granting importance. If you wish to create boldface text, you should use the CSS font-weight property. If you wish to indicate an element is of special importance, you should use the <strong> element.

Try it

属性

¥Attributes

该元素仅包含 全局属性

¥This element only includes the global attributes.

使用说明

¥Usage notes

  • 对于摘要中的关键字、评论中的产品名称或其他文本范围(其典型表示形式将采用粗体显示)(但不包括任何特殊重要性)的情况,请使用 <b>
  • 请勿将 <b> 元素与 <strong><em><mark> 元素混淆。<strong> 元素代表具有一定重要性的文本,<em> 对文本有一定的强调,<mark> 元素代表具有一定相关性的文本。<b> 元素不传达这种特殊的语义信息;仅当没有其他适合时才使用它。
  • 同样,不要使用 <b> 元素标记标题和标题。为此,请使用 h1h6 标签。此外,样式表可以更改这些元素的默认样式,从而使它们不一定以粗体显示。
  • 最好在 <b> 元素上使用 class 属性,以便根据需要传达附加语义信息(例如,段落中的第一句使用 <b class="lead">)。如果你的风格需求发生变化,这可以更轻松地管理 <b> 的多个用例,而无需更改其在 HTML 中的所有用途。
  • 从历史上看,<b> 元素旨在使文本变为粗体。自 HTML4 以来,样式信息已被弃用,因此 <b> 元素的含义已更改。
  • 如果使用 <b> 元素没有语义目的,则应使用值为 "bold" 的 CSS font-weight 属性,以使文本变为粗体。

示例

¥Examples

html
<p>
  This article describes several <b class="keywords">text-level</b> elements. It
  explains their usage in an <b class="keywords">HTML</b> document.
</p>
Keywords are displayed with the default style of the
<b>element, likely in bold.</b>

结果

¥Result

技术总结

¥Technical summary

内容类别 流量内容措辞内容,可触及的内容。
允许的内容 措辞内容.
标签遗漏 无,开始和结束标记都是强制性的。
允许的父级 任何接受 措辞内容 的元素。
隐式 ARIA 角色 generic
允许的 ARIA 角色 任何
DOM 接口 HTMLElement

规范

Specification
HTML Standard
# the-b-element

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看