blob: 860165d4c48d9e14547313b078b4b6218436a7bc (
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
---
title: <data>
slug: Web/HTML/Element/data
tags:
- HTML
- Web
- 元素
- 参考
translation_of: Web/HTML/Element/data
---
<div>{{HTMLRef}}</div>
<p><strong>HTML <code><data></code> 元素</strong>将一个指定内容和机器可读的翻译联系在一起。但是,如果内容是与时间或者日期相关的,则一定要使用 {{HTMLElement("time")}}。</p>
<div>{{EmbedInteractiveExample("pages/tabbed/data.html", "tabbed-shorter")}}</div>
<table class="properties">
<tbody>
<tr>
<th scope="row"><a href="/en-US/docs/Web/HTML/Content_categories">Content categories</a></th>
<td><a href="/en-US/docs/Web/HTML/Content_categories#Flow_content">Flow content</a>, <a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content">phrasing content</a>, palpable content.</td>
</tr>
<tr>
<th scope="row">Permitted content</th>
<td><a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content">Phrasing content</a>.</td>
</tr>
<tr>
<th scope="row">Tag omission</th>
<td>{{no_tag_omission}}</td>
</tr>
<tr>
<th scope="row">Permitted parents</th>
<td>Any element that accepts <a href="/en-US/docs/Web/HTML/Content_categories#Phrasing_content">phrasing content</a>.</td>
</tr>
<tr>
<th scope="row">DOM 接口</th>
<td>{{domxref("HTMLDataElement")}}</td>
</tr>
</tbody>
</table>
<h2 id="属性">属性</h2>
<p>该元素支持<a href="/zh-CN/docs/HTML/Global_attributes">全局属性</a>。</p>
<dl>
<dt>{{htmlattrdef("value")}}</dt>
<dd>该属性指定元素内容所对应的数据,或者说“机器可读的翻译”。</dd>
</dl>
<h2 id="示例">示例</h2>
<p>下面的示例展示了一些产品名称,而且每个名称都和一个产品编码相关联。</p>
<pre class="brush: html"><p>新产品</p>
<ul>
<li><data value="398">迷你番茄酱</data></li>
<li><data value="399">巨无霸番茄酱</data></li>
<li><data value="400">超级巨无霸番茄酱</data></li>
</ul>
</pre>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">规范</th>
<th scope="col">状态</th>
<th scope="col">备注</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-data-element', '<data>')}}</td>
<td>{{Spec2('HTML WHATWG')}}</td>
<td>No change from {{Spec2('HTML5 W3C')}}</td>
</tr>
<tr>
<td>{{SpecName('HTML5 W3C', 'text-level-semantics.html#the-data-element', '<data>')}}</td>
<td>{{Spec2('HTML5 W3C')}}</td>
<td>Initial definition.</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("html.elements.data")}}</p>
<h2 id="参见">参见</h2>
<ul>
<li>HTML {{HTMLElement("time")}} 元素。</li>
</ul>
|