本文介绍了< strong> vs. font-weight:bold& < em> vs font-style:italic的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用< strong> < em> 之间有什么真正的区别, :

  font-weight:bold; 
font-style:italic;

此外,这两个选项的真正原因是什么?我可能错了,但是没有< strong> < em> font-weight font-style 成为标准CSS属性?

解决方案

HTML代表含义; CSS表示外观。如何标记文档中的文本不是由文本在屏幕上显示的方式决定的,而只是它的含义。作为另一个示例,一些其他HTML元素(如标题)默认样式为 font-weight:bold ,但是使用< h1> ; - < h6> ,不是< strong> c>< b> 。



在HTML5中,您使用来表示句子的重要部分,例如:

 < p>< strong>请勿触摸。< / strong>包含< strong>有害< / strong>材料。 

您使用,以表示语言压力,例如:

 < p>一个绅士:我想他是这样的。但是没有要求。 
< p>一位女士:为什么不?
< p>一个绅士:因为他不行。
< p>一位女士:他不< em>行< / em> ;?
< p> A绅士:不。他< em>不< / em>行。
< p>一位女士:啊。我明白你的意思了。

这些元素是刚刚出现粗体 >斜体表示形式,但您可以根据自己喜欢的样式。例如,在上面的< em> 示例中,您可以用大写而不是斜体表示应力强调,但是 > 元素保持不变 - 通过在其他元素上强调特定词语或短语来更改句子的上下文:

  em {
font-style:normal;
text-transform:uppercase;
}

请注意,原始答案(下面)应用于HTML5之前的HTML标准,其中< strong> < em> 有一些不同的含义,和纯粹是表现的,没有任何语义意义。分别像< strong> < em> ,它们具有相似的表示默认值, / p>




您使用< strong> < em> 分别表示强调重点和正常强调。



- >< strong> 更接近< b> < i> < em>更接近 font-style:italic 。这些视觉样式纯属视觉:像屏幕阅读器这样的工具不会理解粗体和斜体的含义,但某些屏幕阅读器以更强调的音调阅读< strong> < em> 文字。 $ b

Is there any real difference between using <strong> and <em> instead of the CSS properties:

font-weight: bold;
font-style: italic;

Also, what is really the reason that both options exist? I could be wrong but didn't <strong> and <em> came on the scene quite a while after font-weight and font-style became standard CSS properties? If so, there must be some reason for them.

解决方案

HTML represents meaning; CSS represents appearance. How you mark up text in a document is not determined by how that text appears on screen, but simply what it means. As another example, some other HTML elements, like headings, are styled font-weight: bold by default, but they are marked up using <h1><h6>, not <strong> or <b>.

In HTML5, you use <strong> to indicate important parts of a sentence, for example:

<p><strong>Do not touch.</strong> Contains <strong>hazardous</strong> materials.

And you use <em> to indicate linguistic stress, for example:

<p>A Gentleman: I suppose he does. But there's no point in asking.
<p>A Lady: Why not?
<p>A Gentleman: Because he doesn't row.
<p>A Lady: He doesn't <em>row</em>?
<p>A Gentleman: No. He <em>doesn't</em> row.
<p>A Lady: Ah. I see what you mean.

These elements are semantic elements that just happen to have bold and italic representations by default, but you can style them however you like. For example, in the <em> sample above, you could represent stress emphasis in uppercase instead of italics, but the functional purpose of the <em> element remains the same — to change the context of a sentence by emphasizing specific words or phrases over others:

em {
    font-style: normal;
    text-transform: uppercase;
}

Note that the original answer (below) applied to HTML standards prior to HTML5, in which <strong> and <em> had somewhat different meanings, <b> and <i> were purely presentational and had no semantic meaning whatsoever. Like <strong> and <em> respectively, they have similar presentational defaults but may be styled differently.


You use <strong> and <em> to indicate intense emphasis and normal emphasis respectively.

Or think of it this way: font-weight: bold is closer to <b> than <strong>, and font-style: italic is closer to <i> than <em>. These visual styles are purely visual: tools like screen readers aren't going to understand what bold and italic mean, but some screen readers are able to read <strong> and <em> text in a more emphasized tone.

这篇关于&lt; strong&gt; vs. font-weight:bold&amp; &lt; em&gt; vs font-style:italic的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-09 22:31