CSS 什么时候用<strong>,什么时候用<b>?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3059149/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
When to use <strong> and when to use <b>?
提问by Jitendra Vyas
Possible Duplicate:
Is it ok to use <strong> in place of <b> blindly ?
When to use <strong>
and when to use <b>
or other ways to give look of bold? strong
has semantic value ( and useful for screen reader while b
is presentation (and even valid in HTML 5).
何时使用<strong>
,何时使用<b>
或其他方式使外观看起来更粗?strong
具有语义价值(并且在b
呈现时对屏幕阅读器很有用(甚至在 HTML 5 中有效)。
my question is not what is the difference between strong
and b
.
我的问题不是strong
和之间有什么区别b
。
The question is when to use semantic tag and when to use just to make text bold
问题是何时使用语义标签以及何时使用仅使文本加粗
Should I always use <strong>
if client's content files (MS word files) has some words boldin content paragraphs?
<strong>
如果客户的内容文件(MS word 文件)在内容段落中有一些粗体字,我应该总是使用吗?
alt text http://shup.com/Shup/365676/11051764618-My-Desktop.png
替代文字 http://shup.com/Shup/365676/11051764618-My-Desktop.png
How can we know when client want to give emphasis to text and when he just want to make text bold for presentation/aesthetic purpose?
我们怎么知道客户什么时候想要强调文本,什么时候他只想将文本加粗以用于演示/美学目的?
If it's client job to tell us, then how to explain this scenario to client to give us clear info on "when he just want to make text bold for presentation/aesthetic purpose" ?
如果告诉我们是客户的工作,那么如何向客户解释这种情况,以向我们提供有关“何时他只想将文本加粗以用于演示/美学目的”的明确信息?
采纳答案by takeshin
How can we know when client want to give emphasis to text and when he just want to make text bold for presentation/aesthetic purpose?
我们怎么知道客户什么时候想要强调文本,什么时候他只想将文本加粗以用于演示/美学目的?
Read the client's text with understanding.
带着理解阅读客户的文字。
- use
<strong>
when the context says that the bold text is more important than the other (and it is inline) - use
<b>
if it just should be bold (even in database, feed reader or without stylesheets). In this case boldness may be used to catch the readers eye.
- 使用
<strong>
时上下文说,大胆的文字比其他更重要(它是在线) - 使用
<b>
粗体(即使在数据库、提要阅读器或没有样式表中)。在这种情况下,可以使用大胆来吸引读者的眼球。
When in doubt, ask the client what did he meant.
如有疑问,请询问客户他的意思。
To save you and yourself a hassle, ask the client to use formatting stylesin his editor. This is very useful feature, pity that there few people who do know what for this feature is.
为了省去您和您自己的麻烦,请让客户在他的编辑器中使用格式样式。这是一个非常有用的功能,可惜很少有人知道这个功能是什么。
Edit:
编辑:
This is strongand this is bold. Any difference?
这是强大的,这是大胆的。有什么区别吗?
All the problems begin here. If the strong
were by default colored RED (no red markup on SO), and normal weight, there would be no questions like this.
所有的问题都从这里开始。如果strong
默认情况下为红色(SO 上没有红色标记)和正常重量,就不会有这样的问题。
回答by Chris
I've always followed a simple rule of thumb:
我一直遵循一个简单的经验法则:
<strong>
means "strong emphasis", and implies no particular visual style. It has semantic meaning, but could look like anything.<b>
is used to apply a bold visual effect to text, but is a presentational tag like<font>
and so should be avoided (where possible) in favour of CSS.
<strong>
意为“强烈强调”,并暗示没有特别的视觉风格。它具有语义意义,但可以看起来像任何东西。<b>
用于对文本应用粗体视觉效果,但它是一个展示标签<font>
,因此应该避免(在可能的情况下)以支持 CSS。
回答by Jeremy McGee
There's no "right" answer to this (which is probably why semantic markup isn't in a good state).
对此没有“正确”的答案(这可能是语义标记状态不佳的原因)。
Depending on the way your client works I'd say your proposal to replace emboldened content in paragraphs with <strong>
, and everything else with relevant heading styles, is reasonable. It may be a good idea to sample the documents to establish what practice has been used.
根据您客户的工作方式,我会说您建议将段落中的大胆内容替换为<strong>
,并使用相关标题样式替换其他所有内容,这是合理的。对文档进行抽样以确定所使用的实践可能是一个好主意。
回答by Alohci
First ask the client "why have you highlighted these words?" and use that to inform your decision. If you can't get a clear answer, I'd use <B> since it's better to not imply that there are semantics to the highlighted words when in fact there are none. Use of <B> can be used as a clear indication that you have unsatifactory presentational markup, and therefore helpful to future maintainers that it can be freely corrected in the light of new information about the reason for the highlighting.
首先问客户“你为什么强调这些词?” 并使用它来通知您的决定。如果你不能得到一个明确的答案,我会使用 <B> 因为最好不要暗示突出显示的单词有语义,而实际上没有。使用 <B> 可以清楚地表明您有不令人满意的表示标记,因此有助于未来的维护者可以根据有关突出显示原因的新信息自由更正。
回答by mouviciel
Using CSS to define a style other than default bold for a <strong>
tag is understandable.
使用 CSS 定义<strong>
标签的默认粗体以外的样式是可以理解的。
Using CSS the same way on a <b>
tag would be more questionable.
在<b>
标签上以同样的方式使用 CSS会更成问题。
回答by Dean Harding
If you're doing a conversion of a word document to HTML, then I think <b>
is a better choice, because you're conveying the fact that the text was boldin the word document. Word uses stylesto apply semantic meaning, so if it's marked with the "Strong" style, then you use the <strong>
tag in the HTML.
如果您正在将 word 文档转换为 HTML,那么我认为这<b>
是一个更好的选择,因为您要传达这样一个事实,即word 文档中的文本是粗体的。Word 使用样式来应用语义,因此如果它标有“强”样式,则您<strong>
在 HTML 中使用该标签。