有没有一种语义方法可以用 html 和 html 去强调文本? CSS?
我通常在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,在您的情况下
是合适的元素,尽管它不会“弱化”文本。
当前 html 规范中的行:
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:
http://www.w3.org/TR/html5/text-level-semantics.html#the-small-element
正常字体颜色为黑色 (#000)。将颜色调整为较浅的版本将弱化文本片段。
Strong 是一个强调文本的标签,所以我建议使用
代替。
结果: 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.Result: http://jsfiddle.net/rzHgW/