Html <small> 标签的正确使用,或如何标记“不太重要”的文本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10465973/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:11:49  来源:igfitidea点击:

Correct use of the <small> tag, or how to markup "less important" text

htmlsemantic-markup

提问by Wesley Murch

Yet another tag that was given new meaning in HTML5, <small>apparently lives on:

另一个在 HTML5 中被赋予新含义的标签<small>显然仍然存在:

http://www.w3.org/TR/html-markup/small.html#small

The small element represents so-called “fine print” or “small print”, such as legal disclaimers and caveats.

http://www.w3.org/TR/html-markup/small.html#small

小元素代表所谓的“小字”或“小字”,例如法律免责声明和警告。

This unofficial reference seems to take it a little further:

这个非官方参考似乎更进一步:

http://html5doctor.com/small-hr-element/

<small>is now for side comments, which are the inline equivalent of <aside>— content which is not the main focus of the page. A common example is inline legalese, such as a copyright statement in a page footer, a disclaimer, or licensing information. It can also be used for attribution.

http://html5doctor.com/small-hr-element/

<small>现在用于旁注,这是内联等效于 <aside>- 不是页面主要焦点的内容。一个常见的例子是内联法律术语,例如页脚中的版权声明、免责声明或许可信息。它也可以用于归因。

I have a list of people I want to display, which includes their real name and nickname. The nickname is sort of an "aside", and I want to style it with lighter text:

我有一个要显示的人员列表,其中包括他们的真实姓名和昵称。昵称有点像“旁边”,我想用更轻的文字来设计它:

<li>Laurence Tureaud <small>(Mr.T)</small></li>

enter image description here

在此处输入图片说明

I'll need to do something like this for several sections of the site (people, products, locations), so I'm trying to develop a sensible standard. I know I can use <span class="quiet">or something like that, but I'm trying to avoid arbitrary class names and use the correct HTML element (if there is one).

我需要为网站的几个部分(人员、产品、位置)做这样的事情,所以我正在努力制定一个合理的标准。我知道我可以使用<span class="quiet">或类似的东西,但我试图避免任意的类名并使用正确的 HTML 元素(如果有的话)。

Is <small>appropriate for this, or is there another element or markup structure that would be appropriate?

是否<small>适合于此,或者是否有其他合适的元素或标记结构?

采纳答案by skyline26

The spec you're looking at is old, you should look at the HTML5 spec:

您正在查看的规范很旧,您应该查看 HTML5 规范:

https://html.spec.whatwg.org/multipage/

https://html.spec.whatwg.org/multipage/

I suggest <em>here instead of small:

我建议<em>这里而不是小:

<p>Laurence Tureaud also called <em>Mr. T</em> is famous for his role
in the tv series A-TEAM.</p>

<small>is not used commonly in an article sentence, but like this:

<small>在冠词句子中不常用,但像这样:

<footer>
    <p>
    Search articles about <a href="#">Laurence Tureaud</a>,
    <small>or try <a href="#">articles about A-TEAM</a>.</small>
    </p>
</footer>

<footer>
    <p>
    Call the Laurence Tureaud's "life trainer chat line" at
    555-1122334455 <small>(.99 for 1 minute)</small>
    </p>
</footer>

Article sentence:

文章语句:

<p>
    My job is very interesting and I love it: I work in an office
    <small>(123 St. Rome, Italy)</small> with a lot of funny guys that share
    my exact interests.
</p>

回答by AverageMarcus

Personally I would think <small>would not be the correct tag for this as it suggests the text will be physically smaller which doesn't seem to be the case with your example. I think using a <span>would be more appropriate or possible the HTML <aside>. http://dev.w3.org/html5//spec-author-view/the-aside-element.html

就我个人而言,我认为<small>这不是正确的标签,因为它表明文本在物理上会更小,而您的示例似乎并非如此。我认为使用 a<span>会更合适或更可能是 HTML <aside>http://dev.w3.org/html5//spec-author-view/the-aside-element.html

回答by Jukka K. Korpela

You should ask yourself how you would prefer the document to be displayed when style sheets are not applied. Select the markup according to this, instead of scholarly or scholastic theories about “semantic markup” (see my pragmatic guide to HTML).

您应该问问自己,当不应用样式表时,您希望如何显示文档。根据此选择标记,而不是关于“语义标记”的学术或学术理论(请参阅我的HTML 实用指南)。

If smaller size is what you want, then use <small>or <font size=2>. The former is more concise and easier to style, and it is more “resistant” (on some browsers, settings that tell the browser to ignore font sizes specified on web pages do not remove the effect of small). So it's a rather simple choice.

如果您想要更小的尺寸,请使用<small><font size=2>。前者更简洁,更易于样式化,并且更“耐”(在某些浏览器上,告诉浏览器忽略网页上指定的字体大小的设置不会消除 的效果small)。所以这是一个相当简单的选择。

On the other hand, font size variation inside a line of text is typographically questionable. In printed matter, it is much more often accidental, an error, rather than intentional. Putting something in parentheses is normally a sufficient indication of being somehow secondary

另一方面,一行文本内的字体大小变化在排版上是有问题的。在印刷品中,它通常是偶然的、错误的,而不是故意的。把一些东西放在括号里通常足以表明在某种程度上是次要的