<dfn>:定义元素
<dfn>
HTML 元素指示要定义的术语。<dfn>
元素应在完整的定义语句中使用,其中术语的完整定义可以是以下之一:
¥The <dfn>
HTML element indicates a term to be defined. The <dfn>
element should be used in a complete definition statement, where the full definition of the term can be one of the following:
Try it
属性
¥Attributes
该元素的属性包括 全局属性。
¥This element's attributes include the global attributes.
title
属性具有特殊含义,如下所述。
¥The title
attribute has special meaning, as noted below.
使用说明
指定正在定义的术语
¥Specifying the term being defined
所定义的术语是按照以下规则确定的:
¥The term being defined is identified following these rules:
- 如果
<dfn>
元素具有title
属性,则title
属性的值被视为正在定义的术语。该元素中仍必须包含文本,但该文本可以是缩写(可能使用<abbr>
)或该术语的其他形式。 - 如果
<dfn>
包含单个子元素并且没有自己的任何文本内容,并且该子元素是本身具有title
属性的<abbr>
元素,则<abbr>
元素的title
的确切值就是所定义的术语。 - 否则,
<dfn>
元素的文本内容就是正在定义的术语。显示为 在下面的第一个例子中。
注意:如果
<dfn>
元素具有title
属性,则它必须包含正在定义的术语,并且不得包含其他文本。¥Note: If the
<dfn>
element has atitle
attribute, it must contain the term being defined and no other text.
<dfn>
元素的链接
¥Links to <dfn>
elements
如果你在 <dfn>
元素上包含 id
属性,则可以使用 <a>
元素链接到它。此类链接应该是该术语的使用,目的是读者可以通过单击该术语的链接快速导航到该术语的定义(如果他们还不知道)。
¥If you include an id
attribute on the <dfn>
element, you can then link to it using <a>
elements. Such links should be uses of the term, with the intent being that the reader can quickly navigate to the term's definition if they're not already aware of it, by clicking on the term's link.
这如下面 定义链接 下的示例所示。
¥This is shown in the example under Links to definitions below.
示例
术语的基本识别
¥Basic identification of a term
此示例使用纯 <dfn>
元素来标识术语在定义中的位置。
¥This example uses a plain <dfn>
element to identify the location of a term within the definition.
HTML
<p>
The <strong>HTML Definition element (<dfn><dfn></dfn>)</strong> is used
to indicate the term being defined within the context of a definition phrase
or sentence.
</p>
由于 <dfn>
元素没有 title
,因此 <dfn>
元素本身的文本内容用作所定义的术语。
¥Since the <dfn>
element has no title
, the text contents of the <dfn>
element itself are used as the term being defined.
结果
¥Result
定义链接
¥Links to definitions
要向定义添加链接,你可以像往常一样使用 <a>
元素创建链接。
¥To add links to the definitions, you create the link the same way you always do, with the <a>
element.
HTML
<p>
The
<strong>HTML Definition element (<dfn id="definition-dfn"><dfn></dfn>)</strong>
is used to indicate the term being defined within the context of a definition
phrase or sentence.
</p>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Graece donan, Latine
voluptatem vocant. Confecta res esset. Duo Reges: constructio interrete.
Scrupulum, inquam, abeunti;
</p>
<p>
Because of all of that, we decided to use the
<code><a href="#definition-dfn"><dfn></a></code> element for this
project.
</p>
这里我们看到了定义 - 现在有一个 id
属性,"definition-dfn"
,它可以用作链接的目标。随后,使用 <a>
创建链接,并将 href
属性设置为 "#definition-dfn"
,以设置返回到定义的链接。
¥Here we see the definition — now with an id
attribute, "definition-dfn"
, which can be used as the target of a link. Later on, a link is created using <a>
with the href
attribute set to "#definition-dfn"
to set up the link back to the definition.
结果
¥Result
一起使用缩写和定义
¥Using abbreviations and definitions together
在某些情况下,你可能希望在定义术语时使用术语的缩写。这可以通过串联使用 <dfn>
和 <abbr>
元素来完成,如下所示:
¥In some cases, you may wish to use an abbreviation for a term when defining it. This can be done by using the <dfn>
and <abbr>
elements in tandem, like this:
HTML
<p>
The <dfn><abbr title="Hubble Space Telescope">HST</abbr></dfn> is among the
most productive scientific instruments ever constructed. It has been in orbit
for over 20 years, scanning the sky and returning data and photographs of
unprecedented quality and detail.
</p>
<p>
Indeed, the <abbr title="Hubble Space Telescope">HST</abbr> has arguably done
more to advance science than any device ever built.
</p>
请注意嵌套在 <dfn>
内的 <abbr>
元素。前者确定该术语是缩写 ("HST"),并在其 title
属性中指定完整术语 ("哈勃太空望远镜")。后者表明缩写术语代表正在定义的术语。
¥Note the <abbr>
element nested inside the <dfn>
. The former establishes that the term is an abbreviation ("HST") and specifies the full term ("Hubble Space Telescope") in its title
attribute. The latter indicates that the abbreviated term represents a term being defined.
结果
¥Result
技术总结
规范
Specification |
---|
HTML Standard # the-dfn-element |
浏览器兼容性
BCD tables only load in the browser