<strong>: The Strong Importance element - HTML: HyperText Markup Language 编辑

The HTML Strong Importance Element (<strong>) indicates that its contents have strong importance, seriousness, or urgency. Browsers typically render the contents in bold type.

Content categoriesFlow content, phrasing content, palpable content.
Permitted contentPhrasing content.
Tag omissionNone, must have both a start tag and an end tag.
Permitted parentsAny element that accepts phrasing content, or any element that accepts flow content.
Implicit ARIA roleNo corresponding role
Permitted ARIA rolesAny
DOM interfaceHTMLElement

Attributes

This element only includes the global attributes.

Usage notes

The <strong> element is for content that is of "strong importance," including things of great seriousness or urgency (such as warnings). This could be a sentence that is of great importance to the whole page, or you could merely try to point out that some words are of greater importance compared to nearby content.

Typically this element is rendered by default using a bold font weight. However, it should not be used to apply bold styling; use the CSS font-weight property for that purpose. Use the <b> element to draw attention to certain text without indicating a higher level of importance. Use the <em> element to mark text that has stress emphasis.

Another accepted use for <strong> is to denote the labels of paragraphs which represent notes or warnings within the text of a page.

<b> vs. <strong>

It is often confusing to new developers why there are so many ways to express the same thing on a rendered website. <b> and <strong> are perhaps one of the most common sources of confusion, causing developers to ask "Should I use <b> or <strong>? Don't they both do the same thing?"

Not exactly. The <strong> element is for content that is of greater importance, while the <b> element is used to draw attention to text without indicating that it's more important.

It may help to realize that both are valid and semantic elements in HTML5 and that it's a coincidence that they both have the same default styling (boldface) in most browsers (although some older browsers actually underline <strong>). Each element is meant to be used in certain types of scenarios, and if you want to bold text for decoration, you should instead actually use the CSS font-weight property.

The intended meaning or purpose of the enclosed text should be what determines which element you use. Communicating meaning is what semantics are all about.

<em> vs. <strong>

Adding to the confusion is the fact that while HTML 4 defined <strong> as indicating a stronger emphasis, HTML 5 defines <strong> as representing "strong importance for its contents." This is an important distinction to make.

While <em> is used to change the meaning of a sentence as spoken emphasis does ("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 <em> can be nested to increase the relative degree of importance or stress emphasis, respectively.

Examples

Basic example

<p>Before proceeding, <strong>make sure you put on your safety goggles</strong>.</p>

The resulting output:

Labeling warnings

<p><strong>Important:</strong> Before proceeding, make sure you add plenty of butter.</p>

This results in:

Specifications

SpecificationStatusComment
HTML Living Standard
The definition of '<strong>' in that specification.
Living Standard
HTML5
The definition of '<strong>' in that specification.
Recommendation
HTML 4.01 Specification
The definition of '<strong>' in that specification.
Recommendation

Browser compatibility

BCD tables only load in the browser

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:120 次

字数:9138

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文