HTML的small标签


HTML小字标签(small)

HTML的小字标签用于定义一行或部分文本的小号字体。这个标记通常用来标记术语、注释、法律声明以及其他小型文本内容。因为小字体标签可以使文本更加易读并且引导读者注意更重要的内容。

语法

HTML小字标记使用<small></small>来开始和结束,像这样:

<small> This is some small text </small>

小字标签的使用方法

下面是一些使用小字体标记的例子:

<p> The following terms apply to your use of this website: <br>
<small>By accessing this website, you agree to these terms. If you do not agree to these terms, please do not use our website.</small>
</p>

输出:

The following terms apply to your use of this website:
By accessing this website, you agree to these terms. If you do not agree to these terms, please do not use our website.

在这个例子中,小字体标记使用来使带有通知性的文本更加突出。

<h2>The Great Smoky Mountains</h2>
<p> The Great Smoky Mountains are located in Tennessee
and North Carolina. They are part of the <em>Appalachian Mountains</em>.
The <small>Smoky Mountains</small> have been a national park since 1934.</p>

输出:

The Great Smoky Mountains

The Great Smoky Mountains are located in Tennessee and North Carolina. They are part of the Appalachian Mountains. The Smoky Mountains have been a national park since 1934.

在这个例子中,小字体标记使用来使 “Smoky Mountains” 更加显眼,使得读者更容易注意到。这种标记的出现可以为特别的词语或短语添加重点,并使之与其他文本区分开来。

属性

小字体标记不支持任何属性。

小字标签的替代标记

小字体标记被认为是过时的标记。HTML5指南建议使用<small>标记的替代标记是使用CSS或者HTML5的语义标记实现同样的效果。

对于小型文本和注释,可以使用<small>标记的替代标记<span>简单地在CSS上设置字体大小,像这样:

span.small-text {
    font-size:0.8rem;
}

然后再使用如下的HTML代码:

<span class="small-text">This is some small text</span>

使用CSS实现这个功能最终达到的一般效果与使用HTML <small> 标记相同。

总结

小字体标记如果陈旧的标记之一,虽然它对文本进行了增强,但HTML5推荐使用CSS或HTML5语义标记来实现同样的功能,这也更加符合现代化的开发理念。大多数情况下,使用CSS来指定要小型化的文本的字体大小是更加灵活并且更加现代化的技术。