开发者

Is it bad practise to use the <b> tag? [duplicate]

This question already has answers here: Closed 11 years ago.

Possible Duplicates:

Is it ok to use <strong> in place of <b> blindly ?

What's the difference between <b> and <strong>, <i> and <em>?

If so why? I have been told by two develope开发者_StackOverflow中文版rs I do free lance work for, not to use the b tag and instead to use strong. But neither have been able to tell me why exactly.

I rather use b since it's faster to write unless there is a specific reason I shouldn't.


<strong> means strong emphasis. The idea is that when using a different medium (e.g., text-to-speech), you can express strong emphasis through changing the tone.

<b> means bold. That makes no sense outside of screen display, and more importantly, doesn't explain why something is bold.


HTML5 gives the <b> tag a new, semantic usage:

The b element represents a span of text to be stylistically offset from the normal prose without conveying any extra importance, such as key words in a document abstract, product names in a review, or other spans of text whose typical typographic presentation is boldened.

http://dev.w3.org/html5/spec/text-level-semantics.html#the-b-element

<strong> is different:

The strong element represents strong importance for its contents.

http://dev.w3.org/html5/spec/text-level-semantics.html#the-strong-element


In HTML 4 and XHTML 1, b is a presentational element. It means nothing except "This should be rendered in a bold typeface". Presentation is the job of CSS. HTML is for structure and semantics. If you just want a bold typeface, you should use the CSS font-weight property (along with whatever markup is semantically closest to the content you are marking up).

strong, on the other hand, means "this content has stronger (than em) emphasis". The markup continues to make sense for outputs that can't render using a bold typeface (such as a screen reader) or if (in the future) you decide you want to render your emphasis with (for example) a different background colour instead.


The <b> element means - bold, which is a UI concern that should be put in CSS, not in your markup. If you just want to apply a style without meaning, use <b>.

<strong> is semantic - it means that the text is important, whatever that means for your display (or text reader). If there is meaning to having the text marked this way (without any visual concerns), use <strong>.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜