HTML - <dfn> 標籤



HTML <dfn> 標籤代表“定義”。<dfn> 標籤用於指示在定義短語或句子上下文中定義的術語。

如果術語包含在 <dfn> 元素中,則瀏覽器理解該文字是該術語的定義。此 <dfn> 標籤採用 title 屬性,該屬性指定術語的定義,並在滑鼠懸停在其上時顯示。

使用 HTML dfn 標籤的規則

  • 如果 <dfn> 包含單個子元素並且本身沒有任何文字內容,則在 <dfn> 標籤內新增 <abbr> 標籤。
  • 或者,新增 id 屬性。然後,每當使用術語時,可以使用 <a> 標籤引用定義。

語法

<dfn title=".."> .... </dfn>

屬性

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

HTML dfn 標籤示例

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

指定 dfn 元素

在以下示例中,我們正在建立 HTML 文件並使用 <dfn> 標籤而不使用 title 屬性。

<!DOCTYPE html>
<html>
<body>
   <p>
      <dfn>tutorialspoint</dfn> is the EdTech company
      that provides good courses and technical tutorials for every 
      technologies.
   </p>
</body>
</html>

使用 title 屬性指定 dfn 元素

考慮以下示例,我們正在建立 HTML 文件並使用帶有 title 屬性的 <dfn> 標籤。

<!DOCTYPE html>
<html>
<body>
   <p>
      <dfn title="ReactJS">ReactJS</dfn> is the 
      library of the JavaScript language!.
   </p>
</body>
</html>

使用 abbr 標籤指定 dfn 元素

讓我們看看以下示例,我們正在建立 HTML 文件並在 <dfn> 標籤 內使用 <abbr> 標籤。

<!DOCTYPE html>
<html>
<body>
   <p>
      <dfn>
      <abbr title="Hypertext Markup Language">HTML</abbr>
      </dfn> is the standard markup language for creating web pages.
   </p>
</body>
</html>

使用 id 屬性指定 dfn 元素

以下是示例,我們將向 <dfn> 標籤新增id 屬性,以便每當使用一個詞時,都可以使用 <a> 標籤將其連結到定義。

<!DOCTYPE html>
<html>
<body>
   <p>
      <dfn id="definition-dfn">HTML Definition element</dfn> 
      is used to indicate the term being defined within the 
      context of a definition phrase or sentence.
   </p>
   <p>
      Because of all of that, we decided to use the 
      <a href="#definition-dfn">HTML dfn tag</a> 
   </p>
</body>
</html>

支援的瀏覽器

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