aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/html/element/tt/index.html
blob: 4797e986a3d8a4cc988d0592d1517c6d3b096cad (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
---
title: <tt>
slug: Web/HTML/Element/tt
translation_of: Web/HTML/Element/tt
---
<div>{{ obsolete_header() }}</div>

<h2 id="概述">概述</h2>

<p>HTML 电报文本元素 (<code>&lt;tt&gt;</code>) 产生一个内联元素,使用浏览器内置的 monotype 字体展示。这个元素用于给文本排版,使其等宽展示,就像电报那样。使用 {{ HTMLElement("code") }} 元素来展示等宽文本可能更加普遍。</p>

<div class="note">这个元素已废弃。使用更加适当的元素,例如带有 <a href="/fr/docs/CSS" title="/fr/docs/CSS">CSS</a> 的 {{ HTMLElement("code") }} 或者 {{ HTMLElement("span") }} 来代替。</div>

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

<p>这个元素除了<a href="/en-US/docs/Web/HTML/global_attributes" title="HTML/global attributes">全局属性</a>之外,没有其它属性,所有元素都一样。</p>

<h2 id="DOM_接口">DOM 接口</h2>

<p>这个元素实现了 {{domxref('HTMLElement')}} 接口。</p>

<div class="note">
<p><strong>实现注解: </strong>Gecko 1.9.2(包含)之前, Firefox 为这个元素实现了 {{domxref('HTMLSpanElement')}} 接口。</p>
</div>

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

<pre class="brush:html">&lt;p&gt;Enter the following at the telnet command prompt: &lt;code&gt;set localecho&lt;/code&gt;&lt;br /&gt;

The telnet client should display: &lt;tt&gt;Local Echo is on&lt;/tt&gt;&lt;/p&gt;
</pre>

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

<p>Enter the following at the telnet command prompt: <code>set localecho</code><br>
 The telnet client should display: <code>Local Echo is on</code></p>

<h2 id="Notes" name="Notes"></h2>

<ul>
 <li>CSS 规范可以为 <code>tt</code> 选择器定义,来覆盖浏览器的默认字体。用于设置的偏好可能优先于指定的 CSS。</li>
 <li>虽然这个元素没有在 HTML 4.01 规范中废弃,为了支持样式表,不建议使用它。</li>
</ul>

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

<ul>
 <li>{{ HTMLElement("code") }}</li>
 <li>HTML 4.01 规范:<a class="external" href="http://www.w3.org/TR/html4/present/graphics.html#h-15.2">字体样式</a></li>
</ul>

<div>{{ HTMLRef }}</div>