网页设计基础学习-HTML格式

网页设计基础学习-HTML格式

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>

这个例子说明了在HTML里面可以怎样格式化文本。

预格式化文本:

<html>
<body>
<pre>
This is
preformatted text.
It preserves both spaces
and line breaks.
</pre>
<p>The pre tag is good for displaying computer code:</p>
<pre>
for i = 1 to 10
print i
next i
</pre>
</body>
</html>

这个例子说明了可以怎样用pre标签来控制换行和空格。

“计算机输出”标签:

<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>Note:</b> These tags are often used to display computer/programming code.
</p>
</body>
</html>

这个例子说明了“计算机输出”标签在显示上的不同。

地址:

<html>
<body>
<address>
Donald Duck<br>
BOX 555<br>
Disneyland<br>
USA
</address>
</body>
</html>

这个例子说明了如何用HTML书写一个地址。

缩写和首字母缩略法:

<html>
<body>
<abbr title=”United Nations”>UN</abbr>
<br>
<acronym title=”World Wide Web”>WWW</acronym>
<p>The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation.</p>
<p>This only works for the acronym element in IE 5.</p>
<p>This works for both the abbr and acronym element in Netscape 6.2.</p>
</body>
</html>

这个例子说明了如何处理缩写和首字母缩略。

文字方向:

<html>
<body>
<p>
If your browser supports bi-directional override (bdo), the next line will be written from the right to the left (rtl):
</p>
<bdo dir=”rtl”>
Here is some Hebrew text
</bdo>
</body>
</html>

这个例子说明了如何改变文字方向。

块引用:

<html>
<body>
Here comes a long quotation:
<blockquote>
This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation. This is a long quotation.
</blockquote>
Here comes a short quotation:
<q>
This is a short quotation
</q>
<p>
With the block quote element, the browser inserts line breaks and margins, but the q element does not render as anything special.
</p>
</body>
</html>

这个例子说明了如何处理大段引用和小块引用。

删除和插入文字:

<html>
<body>
<p>
a dozen is
<del>twenty </del>
<ins>twelve </ins>
pieces
</p>
<p>
Most browsers will overstrike deleted text and underline inserted text.
</p>
<p>
Some older browsers will display deleted or inserted text as plain text.
</p>
</body>
</html>

这个例子说明了如何标记被删除或者插入的文本。


如何查看HTML源文件

你有没有看过一些网页,并且想知道它是如何做出来的呢?

在浏览器菜单中选择查看——源文件,将弹出一个窗口,这个页面的HTML代码就在其中。

发表评论

电子邮件地址不会被公开。 必填项已用*标注