有没有一种语义方法可以用 html 和 html 去强调文本? CSS?

发布于 2024-12-04 13:08:16 字数 556 浏览 0 评论 0原文

我通常在 HTML(5) 中执行此操作的方式如下:

/* CSS For this example */
footer p {
font-size: 16px;
font-weight: normal;
}

footer strong {
font-weight: bolder;
}

<!-- HTML for this example -->
<footer>
  <p>Title <strong>- Name. 1234 N. Main St., Anytown, USA</strong></p>
</footer>

我这样做的问题是,似乎段落中 90% 的文本被赋予了更大的重要性,这对我来说似乎违反直觉。在我看来,只包装段落中异常的文本(在本例中是较轻的文本)并保留 footer p {font-weight:bold} 更符合语义。

在这里是否是合适的元素,即使它并不是真正的法律免责声明等。

The way I normally would do this in HTML(5) would be like this:

/* CSS For this example */
footer p {
font-size: 16px;
font-weight: normal;
}

footer strong {
font-weight: bolder;
}

<!-- HTML for this example -->
<footer>
  <p>Title <strong>- Name. 1234 N. Main St., Anytown, USA</strong></p>
</footer>

My problem with doing it this way, is that it seems that 90% of the text in the paragraph is given greater importance, which seems counter intuitive to me. It would seem to me to be more semantic to only wrap the text that is abnormal in the paragraph, which in this case is the lighter weight text and leave footer p {font-weight:bold}.

Is <small> the appropriate element here even though its not really for a legal disclaimer, etc.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

極樂鬼 2024-12-11 13:08:16

是的,在您的情况下 是合适的元素,尽管它不会“弱化”文本。

当前 html 规范中的行:

注意:小字体通常包含免责声明、警告、法律
限制或版权。小字体有时也用于
归属,或满足许可要求。

注意:小元素不会“削弱”或降低
em 元素强调或标记为重要的文本的重要性
与强元素。将文本标记为不强调或不重要,
只是不要分别用 em 或 Strong 元素对其进行标记。

http://www.w3.org/ TR/html5/text-level-semantics.html#the-small-element

Yes, in your case <small> is appropriate element, although it does not "de-emphasize" text.

Lines from the current html specifications:

Note: Small print typically features disclaimers, caveats, legal
restrictions, or copyrights. Small print is also sometimes used for
attribution, or for satisfying licensing requirements.

Note: The small element does not "de-emphasize" or lower the
importance of text emphasized by the em element or marked as important
with the strong element. To mark text as not emphasized or important,
simply do not mark it up with the em or strong elements respectively.

http://www.w3.org/TR/html5/text-level-semantics.html#the-small-element

两仪 2024-12-11 13:08:16

正常字体颜色为黑色 (#000)。将颜色调整为较浅的版本将弱化文本片段。

Strong 是一个强调文本的标签,所以我建议使用 代替。

footer small {
    color: #999;
}

结果: http://jsfiddle.net/rzHgW/

The normal font color is black (#000). Adjusting the color, to a lighter version, will de-emphasize the text fragment.

Strong is a tag to emphasize text, so I'd suggest using <small> instead.

footer small {
    color: #999;
}

Result: http://jsfiddle.net/rzHgW/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文