HTML - <i> 標籤



HTML <i> 標籤用於以斜體樣式顯示內容,通常用於不同語言中的重要單詞以及技術術語。如果我們在段落元素內編寫內容,但內容中出現重要單詞或不同語言的單詞,我們可以使用<i> 標籤來突出顯示重要單詞。

語法

<i> content </i>

屬性

HTML i 標籤支援 HTML 的全域性事件屬性。

HTML i 標籤示例

在下面的示例中,我們將看到 i 元素的不同示例。每個示例都將說明 html i 標籤的用例。

指定斜體元素

在以下示例中,讓我們看看 <i> 標籤在 HTML 文件中的工作方式。

<!DOCTYPE html>
<html>
<body>
   <h2>
      <i>This one is italic text</i>
   </h2>
   <p>
      I looked at it and thought 
      <i>This can't be real! </i>
   </p>
   <p>
      The term <i>bandwidth</i> describes the measure
      of how much information can pass through a data connection 
      in a given amount of time.
   </p>
</body>
</html>

設定斜體元素樣式

考慮以下示例,我們正在建立一個 HTML 文件並使用 <i> 標籤建立斜體文字,並使用樣式屬性使斜體文字更具樣式。

<!DOCTYPE html>
<html>
<head>
   <style>
      i {
      color: red;
      }
   </style>
</head>
<body>
   <h2>
      <i>This one is italic text</i>
   </h2>
   <p>
      I looked at it and thought 
      <i>This can't be real! </i>
   </p>
   <p>
      The term <i>bandwidth</i> describes the measure
      of how much information can pass through a data connection 
      in a given amount of time.
   </p>
</body>
</html>

使用斜體元素指示不同的語言

讓我們來看另一個場景,我們將使用 <i> 在文字中指示它是不同語言的。

<!DOCTYPE html>
<html>
<head>
   <style>
      i {
      color: red;
      }
   </style>
</head>
<body>
   <p>
      The Latin phrase <i lang="la">Veni, vidi, 
      vici</i> is often mentioned in music, art, 
      and literature. 
   </p>
</body>
</html>

HTML <i> 標籤用法

當沒有更合適的語義元素時,在任何文字上使用 <i> 標籤。例如<em><strong><mark><cite><dfn>標籤。

支援的瀏覽器

標籤 Chrome Edge Firefox Safari Opera
i
html_tags_reference.htm
廣告