文本格式化
此例演示如何在一个 HTML 文件中对文本进行格式化
<html>
<body>
<b>This text is bold</b>
<br />
<strong>This text is strong</strong>
<br />
<big>This text is big</big>
<br />
<em>This text is emphasized</em>
<br />
<i>This text is italic</i>
<br />
<small>This text is small</small>
<br />
This text contains
<sub>subscript</sub>
<br />
This text contains
<sup>superscript</sup>
</body>
</html>
05 | < b >This text is bold</ b > |
09 | < strong >This text is strong</ strong > |
13 | < big >This text is big</ big > |
17 | < em >This text is emphasized</ em > |
21 | < i >This text is italic</ i > |
25 | < small >This text is small</ small > |
预格式文本
此例演示如何使用 pre 标签对空行和空格进行控制。
<html>
<body>
<pre>
这是
预格式文本。
它保留了 空格
和换行。
</pre>
<p>pre 标签很适合显示计算机代码:</p>
<pre>
for i = 1 to 10
print i
next i
</pre>
</body>
</html>
12 | < p >pre 标签很适合显示计算机代码:</ p > |
“计算机输出”标签
此例演示不同的“计算机输出”标签的显示效果。
<html>
<body>
<code>Computer code</code>
<br />
<kbd>Keyboard input</kbd>
<br />
<tt>Teletype text</tt>
<br />
<samp>Sample text</samp>
<br />
<var>Computer variable</var>
<br />
<p>
<b>注释:</b>这些标签常用于显示计算机/编程代码。
</p>
</body>
</html>
05 | < code >Computer code</ code > |
07 | < kbd >Keyboard input</ kbd > |
11 | < samp >Sample text</ samp > |
13 | < var >Computer variable</ var > |
17 | < b >注释:</ b >这些标签常用于显示计算机/编程代码。 |
地址
此例演示如何在 HTML 文件中写地址。
<!DOCTYPE html>
<html>
<body>
<address>
Written by <a href="mailto:webmaster@example.com">Donald Duck</a>.<br>
Visit us at:<br>
Example.com<br>
Box 564, Disneyland<br>
USA
</address>
</body>
</html>
06 | Written by < a href = "mailto:webmaster@example.com" >Donald Duck</ a >.< br > |
09 | Box 564, Disneyland< br > |
缩写和首字母缩写
此例演示如何实现缩写或首字母缩写。
<html>
<body>
<abbr title="etcetera">etc.</abbr>
<br />
<acronym title="World Wide Web">WWW</acronym>
<p>在某些浏览器中,当您把鼠标移至缩略词语上时,title 可用于展示表达的完整版本。</p>
<p>仅对于 IE 5 中的 acronym 元素有效。</p>
<p>对于 Netscape 6.2 中的 abbr 和 acronym 元素都有效。</p>
</body>
</html>
05 | < abbr title = "etcetera" >etc.</ abbr > |
07 | < acronym title = "World Wide Web" >WWW</ acronym > |
09 | < p >在某些浏览器中,当您把鼠标移至缩略词语上时,title 可用于展示表达的完整版本。</ p > |
11 | < p >仅对于 IE 5 中的 acronym 元素有效。</ p > |
13 | < p >对于 Netscape 6.2 中的 abbr 和 acronym 元素都有效。</ p > |
文字方向
此例演示如何改变文字的方向。
<html>
<body>
<p>
如果您的浏览器支持 bi-directional override (bdo),下一行会从右向左输出 (rtl);
</p>
<bdo dir="rtl">
Here is some Hebrew text
</bdo>
</body>
</html>
06 | 如果您的浏览器支持 bi-directional override (bdo),下一行会从右向左输出 (rtl); |
10 | Here is some Hebrew text |
块引用
此例演示如何实现长短不一的引用语。
<html>
<body>
这是长的引用:
<blockquote>
这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。
</blockquote>
这是短的引用:
<q>
这是短的引用。
</q>
<p>
使用 blockquote 元素的话,浏览器会插入换行和外边距,而 q 元素不会有任何特殊的呈现。
</p>
</body>
</html>
07 | 这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。这是长的引用。 |
16 | 使用 blockquote 元素的话,浏览器会插入换行和外边距,而 q 元素不会有任何特殊的呈现。 |
删除字效果和插入字效果
此例演示如何标记删除文本和插入文本。
<html>
<body>
<p>一打有 <del>二十</del> <ins>十二</ins> 件。</p>
<p>大多数浏览器会改写为删除文本和下划线文本。</p>
<p>一些老式的浏览器会把删除文本和下划线文本显示为普通文本。</p>
</body>
</html>
05 | < p >一打有 < del >二十</ del > < ins >十二</ ins > 件。</ p > |
07 | < p >大多数浏览器会改写为删除文本和下划线文本。</ p > |
09 | < p >一些老式的浏览器会把删除文本和下划线文本显示为普通文本。</ p > |