HTML <small> 标签用于显示版权和法律文本以及其他附带评论。默认情况下,<small> 标签的字体大小较小,并将字体大小减小一个大小(从中到小,从 x-large 到大)并以内联方式显示。
当我们在嵌套形式中使用 <small> 标签时,<small> 标签将相对于父标签的字体大小更改其之间的文本大小。
语法
<small>.....</small>
属性
<small> 标签支持 HTML 的 全局属性和事件属性。
<small> 标签示例
下面的示例将说明<small> 标签的用法,在哪里、何时以及如何使用<small> 标签来显示小文本内容。
使用 <small> 标签创建小元素
在以下示例中,我们将创建一个 HTML 文档,并使用 <small> 标签以小字体表示文本。
<!DOCTYPE html>
<html>
<body>
<h2> QikepuCom</h2>
<small> Example of small tag! </small>
<p>
This is the first sentence.
<small>This whole sentence is in small letters.</small>
</p>
</body>
</html>
使用 CSS 设置小元素的样式
考虑以下示例,我们使用 <small> 标签以及 CSS 属性来设置<small> 标签内容的样式。
<!DOCTYPE html>
<html>
<head>
<style>
h2 {
color: green;
}
span {
color: black;
}
small {
font-style: italic;
color: green;
font-family: courier;
}
</style>
</head>
<body>
<h2> tutorials <span>point</span>
</h2>
<small> Example of small tag! </small>
<p>
This is the first sentence.
<small>This whole sentence is in small letters. </small>
</p>
</body>
</html>
以嵌套方式使用 <small> 标签
让我们看一下下面的例子,我们在嵌套形式中使用 <small> 标签,这意味着 <small> 标签将相对于其周围环境更改其字体。
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-size: 18px;
}
</style>
</head>
<body>
<h2>Welcome To tutorialspoint</h2>
<p>
A nested small tag changes its font size with
respect to the parent tag's font size!
</p>
<p>
This is the first sentence.
<small>This whole sentence is in small letters.</small>
</p>
</body>
</html>
以非嵌套方式使用 <small> 标签
下面是一个示例,我们将以非嵌套形式使用 <small> 标签,如果 <small> 标签用作单独的标签,那么更改任何标签的字体大小都不会影响 <small> 标签的字体大小。
<!DOCTYPE html>
<html>
<head>
<style>
p {
font-size: 25px;
}
</style>
</head>
<body>
<h2>Welcome To tutorialspoint</h2>
<p>This is tutorialspoint </p>
<small>Easy to learn! </small>
</body>
</html>
支持的浏览器
浏览器 | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
<small> | Yes | Yes | Yes | Yes | Yes |