aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/element/bdi/index.html
blob: 334cd83013f3eae2a64c63c1dae5b85b7b458be1 (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
100
101
102
103
---
title: <bdi>
slug: Web/HTML/Element/bdi
tags:
  - BiDi
  - Element
  - HTML
  - HTML text-level semantics
  - Reference
  - Web
translation_of: Web/HTML/Element/bdi
---
<h2 id="Summary">Summary</h2>

<p>{{HTMLRef}}<br>
 <strong>HTML </strong>双向隔离元素 (<strong> <code>&lt;bdi&gt;</code> </strong>) 告诉浏览器的双向算法将其包含的文本与周围的文本隔离,当网站动态插入一些文本且不知道所插入文本的方向性时,此功能特别有用。</p>

<p>{{EmbedInteractiveExample("pages/tabbed/bdi.html", "tabbed-standard")}}</p>



<p class="note">尽管同样的显示效果可以通过使用 CSS 规则 {{cssxref("unicode-bidi")}}:隔离{{HTMLElement("span")}}或者其他文本格式化元素,但语义信息只能通过&lt;bdi&gt;元素传递。特别是,当浏览器允许忽略 CSS 样式时,在这种情况下,使用&lt;bdi&gt;仍然可以保证文本正确显示,而使用 CSS 样式来传递语义时就显得毫无用处。</p>

<table class="properties">
 <tbody>
  <tr>
   <th scope="row"><a href="/en-US/docs/HTML/Content_categories" title="HTML/Content_categories">Content categories</a></th>
   <td><a href="/en-US/docs/HTML/Content_categories#Flow_content" title="HTML/Content categories#Flow content">Flow content</a>, <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="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/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Flow_content">Phrasing content</a>.</td>
  </tr>
  <tr>
   <th scope="row">Tag omission</th>
   <td>{{no_tag_omission}}</td>
  </tr>
  <tr>
   <th scope="row">Permitted parent elements</th>
   <td>Any element that accepts <a href="/en-US/docs/HTML/Content_categories#Phrasing_content" title="HTML/Content_categories#Flow_content">phrasing content</a>.</td>
  </tr>
  <tr>
   <th scope="row">DOM interface</th>
   <td>{{domxref("HTMLElement")}}</td>
  </tr>
 </tbody>
</table>

<h2 id="属性">属性</h2>

<p>{{htmlattrdef("dir")}}</p>

<p>如同其他 HTML 元素一样,它包含<a href="/en-US/docs/HTML/Global_attributes" title="HTML/Global attributes">全局属性</a>,但是有一些语义上的细微差别:<strong>dir</strong>属性不继承父元素。如果没有设置,默认值即为 auto,以便浏览器根据元素内容决定元素内容的方向。</p>

<h2 id="示例">示例</h2>

<pre class="brush: html">&lt;p dir="ltr"&gt;This arabic word &lt;bdi&gt;ARABIC_PLACEHOLDER&lt;/bdi&gt; is automatically displayed right-to-left.&lt;/p&gt;
</pre>

<h3 id="结果">结果</h3>

<p dir="ltr">This arabic word REDLOHECALP_CIBARA is automatically displayed right-to-left.</p>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('HTML WHATWG', 'text-level-semantics.html#the-bdi-element', '&lt;bdi&gt;')}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td></td>
  </tr>
  <tr>
   <td>{{SpecName('HTML5 W3C', 'the-bdi-element.html#the-bdi-element', '&lt;bdi&gt;')}}</td>
   <td>{{Spec2('HTML5 W3C')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

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





<p>{{Compat("html.elements.bdi")}}</p>



<h2 dir="ltr" id="参见">参见</h2>

<ul>
 <li>相关元素: {{HTMLElement("bdo")}}</li>
 <li>相关属性: {{cssxref("direction")}}, {{cssxref("unicode-bidi")}}</li>
</ul>