aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/global_attributes/title/index.html
blob: 1d71da71caf1b08943117f7adcec8e9ff9d69a32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
title: title
slug: Web/HTML/Global_attributes/title
tags:
  - HTML
  - Reference
  - Title
  - 全局属性
translation_of: Web/HTML/Global_attributes/title
---
<p>{{HTMLSidebar("Global_attributes")}}</p>

<p><span class="seoSummary"><strong>title</strong> <a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a> 包含了表示咨询信息文本,和它属于的元素相关。这个信息通常存在,但绝不必要,作为提示信息展示给用户。一些典型用例:</span></p>

<ul>
 <li>链接:被链接文档的标题或描述</li>
 <li>媒体元素,例如图像:描述或关联信息</li>
 <li>段落:脚注或者相关的评论</li>
 <li>引用:作者信息,以及其他</li>
</ul>

<p>如果省略了这个属性,就意味着这个元素的最近祖先的标题仍然是相关的(并且可以用作元素的提示信息)。如果这个属性设为空字符串,它就明确意味着,它的最近祖先的标题是不相关的(并且不应用于这个元素的提示信息)。</p>

<p>额外的语义可以附加到 {{ HTMLElement("link") }}{{ HTMLElement("abbr") }}{{ HTMLElement("input") }} 和 { HTMLElement("menuitem") }} 元素的 <strong>title</strong> 属性。</p>

<p><strong>title</strong> 属性可以包含多行。每个插入的 <code>U+000A LINE FEED</code> (<code>LF</code>) 代表一个换行。有一些需要注意的东西,因为这意味着:</p>

<pre class="brush: html">&lt;p&gt;Newlines in title should be taken into account,like this &lt;abbr title="This is a
multiline title"&gt;example&lt;/abbr&gt;.&lt;/p&gt;
</pre>

<p>这个示例定义了两行的标题。</p>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">格式</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', "elements.html#the-title-attribute", "title")}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>No change from latest snapshot, {{SpecName('HTML5.1')}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5.1', "dom.html#the-title-attribute", "title")}}</td>
   <td>{{Spec2('HTML5.1')}}</td>
   <td>Snapshot of {{SpecName('HTML WHATWG')}}, no change from {{SpecName('HTML5 W3C')}}</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', "dom.html#the-title-attribute", "title")}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td>Snapshot of {{SpecName('HTML WHATWG')}}. From {{SpecName("HTML4.01")}}, it is now a true global attribute.</td>
  </tr>
  <tr>
   <td>{{SpecName('HTML4.01', 'struct/global.html#adef-title', 'title')}}</td>
   <td>{{Spec2('HTML4.01')}}</td>
   <td>Supported on all elements but {{HTMLElement("base")}}, {{HTMLElement("basefont")}}, {{HTMLElement("head")}}, {{HTMLElement("html")}}, {{HTMLElement("meta")}}, {{HTMLElement("param")}}, {{HTMLElement("script")}}, and {{HTMLElement("title")}}.</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

{{Compat("html.global_attributes.title")}}

<h2 id="另见">另见</h2>

<ul>
 <li>所有<a href="/en-US/docs/Web/HTML/Global_attributes">全局属性</a></li>
 <li>反映这个属性的 {{domxref("HTMLElement.title")}} </li>
</ul>