使用 <b> 元素标记关键字而不突出显示它们在语义上是否正确?
Is it semantically correct to use a <b> element to mark up keywords without highlighting them?
我有一个句子,其中包含用另一种语言定义的术语。看完W3Cofficial docs后,我用下面的标记来表达意思:
<p>The <strong><dfn><i lang="tl">barangay</i></dfn></strong> is the <em>smallest</em> <b class="no-bold">political unit</b> in the <b class="no-bold">Philippines</b>.</p>
根据我对文档的理解:
<strong>
非常重要
<dfn>
用于定义实例
<i>
为专业术语and/or音译
<em>
强调强调
<b>
用于突出显示关键字而不将其标记为重要
我不确定是否可以使用 <b>
元素将某些单词和短语标记为 "keywords",而不引起对它们的注意(因此我添加了 class="no-bold"
使用 CSS 改变它的外观)。这是该元素的正确用法吗?
样式不会改变含义。因此,如果在某些上下文中使用带样式的 b
是合适的(例如,将其设为粗体),那么在该上下文中使用不带任何样式的 b
也是合适的。
它是 conceivable that a user-agent makes use of these b
elements,即使您不设置它们的样式或不对它们做任何其他操作。
一个实际的例子:文本浏览器(或 feed 阅读器等,即任何不支持 CSS 的 UA)可能会默认以粗体显示它们。
class
b
元素的名称
然而,class 名称 no-bold
并不理想,因为
- 它将当前样式与内容相结合(您可能想更改样式而不必更改 HTML),并且
- 它没有描述
b
元素的用途(对您的标记的消费者没有用)。
这适用于任何元素,但规范也明确提到了 b
元素:
[…] authors can use the class
attribute on the b
element to identify why the element is being used, so that if the style of a particular use is to be changed at a later date, the author doesn’t have to go through annotating each use.
更合适的名称可能是 definition-keyword
或类似的名称。
我有一个句子,其中包含用另一种语言定义的术语。看完W3Cofficial docs后,我用下面的标记来表达意思:
<p>The <strong><dfn><i lang="tl">barangay</i></dfn></strong> is the <em>smallest</em> <b class="no-bold">political unit</b> in the <b class="no-bold">Philippines</b>.</p>
根据我对文档的理解:
<strong>
非常重要<dfn>
用于定义实例<i>
为专业术语and/or音译<em>
强调强调<b>
用于突出显示关键字而不将其标记为重要
我不确定是否可以使用 <b>
元素将某些单词和短语标记为 "keywords",而不引起对它们的注意(因此我添加了 class="no-bold"
使用 CSS 改变它的外观)。这是该元素的正确用法吗?
样式不会改变含义。因此,如果在某些上下文中使用带样式的 b
是合适的(例如,将其设为粗体),那么在该上下文中使用不带任何样式的 b
也是合适的。
它是 conceivable that a user-agent makes use of these b
elements,即使您不设置它们的样式或不对它们做任何其他操作。
一个实际的例子:文本浏览器(或 feed 阅读器等,即任何不支持 CSS 的 UA)可能会默认以粗体显示它们。
class
b
元素的名称
然而,class 名称 no-bold
并不理想,因为
- 它将当前样式与内容相结合(您可能想更改样式而不必更改 HTML),并且
- 它没有描述
b
元素的用途(对您的标记的消费者没有用)。
这适用于任何元素,但规范也明确提到了 b
元素:
[…] authors can use the
class
attribute on theb
element to identify why the element is being used, so that if the style of a particular use is to be changed at a later date, the author doesn’t have to go through annotating each use.
更合适的名称可能是 definition-keyword
或类似的名称。