HTML - <small>標籤



HTML <small> 標籤用於顯示版權和法律文字以及其他旁註。<small> 標籤預設字型較小,字型大小減小一級(從中等變為小,從特大變為大),並內聯顯示。

當我們在巢狀形式中使用 <small> 標籤時,<small> 標籤會根據父標籤的字型大小更改其間文字的字型大小。

語法

<small>.....</small>

HTML small 標籤示例

下面的示例將說明 small 標籤的用法、何時以及如何使用 small 標籤來顯示少量文字內容。

使用 <small> 標籤建立小元素

在下面的示例中,我們正在建立一個 HTML 文件,並使用 <small> 標籤以小字體表示文字。

<!DOCTYPE html>
<html>
<body>
   <h2> tutorialspoint </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>
標籤 Chrome Edge Firefox Safari Opera
small
html_tags_reference.htm
廣告