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

女生的网名这么多〃 提交于 2019-11-27 11:46:18

As others have mentioned using <strong>, <em>, <cite> etc. adds semantics, and this is important because you say something about why you want to emphasize something, and increases the readability of your html, because you know why its in bold.

Furthermore screen readers use the strong tags to make an audible difference when reading it aloud.

Maybe you could think about the audio represenation as a guide. If you would want a difference when read aloud, mark it as <strong> for instance, if not use <b>.

Then there is the issue of rendering: I don't actually know if all browsers will render a <strong> as a bold and if it will stay that way.

So in short: <strong>No</strong>.

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

No.

To quote Anne van Kesteren (source):

Let me give some contradictory advice. Please do replace em with i and strong with b. The resulting markup is likely more accurate. Especially with WYSIWYG software it is extremely unlikely they will be used correctly, but also because the notion spread that they are interchangeable with the sole difference being that strong and em are semantic a lot of misuse happened. When in doubt, use i and b.

And he’s right, of course. strong and b are not the same. em and i are not the same. Only use strong / em if you want to add semantical emphasis to text.

<b>, <i>, <tt> are strictly typographical.

By saying typographical, I don't mean visual. I mean semantics expressed by the look. They need additional context to have specific meaning (eg. definition, like:

  • text in italics were taken from ...

or relying on typographic convention, like that the text in bold are eye-catchers and the italics mean context change). In typographical conventions bolds and italics are some kind of parenthesis nesting.

(for example [this one has another context])

for example this one has another context

These tags are the port of traditional, printed typography, in which semantics is carried by the specific visual presentation.

As you pointed out, they are considered to be deprecated, but not in XHTML5. Why? I think, mostly that the web content is not only for the e-media. If you print web document, these tags may replace the syntax of some expressions used for example in TeX.

<strong> and <em> are strictly for semantics,

telling how the text should be read and emphasized.

So to recap, none of these tag means the same as other, so they not even should not be used, but may not be used interchangeably, nor substituted. In particular, blindly.

AFIR, Dreamweaver is not the model of the WYSIWYM editor. I have always considered it to be next generation of FrontPage thinking (ease of use and getting things done now, and forget about the future and scalability).

So I understand the surprise here, and your misconception feeling is right :)

We shouldn't swap b and strong blindly as they have different intended purpose.

<b> and <i> are not presentational elements as per the HTML5 spec. They have a different meaning and purpose. Quoting the HTML5 specs,

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.

and for the i element,

The i element represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, a ship name, or some other prose whose typical typographic presentation is italicized.

As others have very well clarified, i and em cannot be used interchangeably and so is the case with b and strong.

The usage of i and b for their intended purpose is very rare. (eg. in dialogue scripts, thesis, resumes)


References:

  1. http://html5doctor.com/i-b-em-strong-element/
  2. http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-i-element

If you just want to use bold text, make it bold via css. If the "bold" font weight has no semantical meaning, you should not use <strong> or <em> for it. However, you shouldn't use <b> or <i> either because these are non-semantic (in fact they are font-style tags) and their use is thus discouraged if not even deprecated.

<b> and <strong> are not necessarily the same. <strong> as you suggested are for higher emphasis, while <b> are for styling purposes only. So you should not switch them blindly.

Some people will say that the <b> tag is being deprecated, but it's not. It's still alive and kicking. However; it is not very semantic, as you're saying, so it might be a better option to use a <span> and style it.

As others have said there's a semantic difference between strong/b and i/em. Especially they are used by screenreaders for visually impaired people visiting your website. For them it makes a huge difference if you just make some text bold-face, or if you want to add some kind of EMphasis to what you're saying on your website. So be sure to carefully consider making something bold using B or STRONG. The same goes for EM and I.

There are some great answers here already, but for those of you that still don't quite understand and need a further explanation and example, I found a useful explanation of this in the HTML Text, Web Platform Docs tutorial. The tutorial explains the difference in use between <strong> and <b> a little past halfway down the page and gives examples.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!