📄 ch53.htm
字号:
<PRE><FONT COLOR="#0066FF"><A HREF="c:\html\home\home.htm">
<A HREF="\usr\tparker\html_source\home.html">
</FONT></PRE>
<P>Relative path references are from the current location and can use valid directory
movement commands. These are valid examples of relative paths in a link:</P>
<PRE><FONT COLOR="#0066FF"><A HREF="..\home.htm">
<A HREF="../../html_source/home.html">
</FONT></PRE>
<P>A link to another URL is much the same as a link to a document, except that you
give the URL after <TT>HREF</TT>. For example, this is a link to the Yahoo! home
page:</P>
<PRE><FONT COLOR="#0066FF"><A HREF="http://www.yahoo.com">Go to Yahoo!</A>
</FONT></PRE>
<P>You can have as many links in your documents as you want. It helps to make the
link description as useful as possible so that users don't end up at pages or sites
they didn't want to access. If you are linking to other sites, you should occasionally
check to make sure that the link is still valid. A lot of home pages change location
or drop off the Web as time goes by, so verify links to avoid annoyed users.
<H3 ALIGN="CENTER"><A NAME="Heading15<FONT COLOR="#000077">Lists</FONT></H3>
<P>HTML lets you use a few different formats of lists, such as ordered, numbered,
labeled, and bulleted. The lists are surrounded by tags such as <TT><OL></TT>
and <TT></OL></TT> (for ordered list) or <TT><MENU></TT> and <TT></MENU></TT>
(for menus). Each item in the list has its own tag, <TT><LI></TT> or something
similar, to separate it from other items. A few special types of list tags are for
handling glossaries and similar purposes, but we'll ignore them in this HTML overview.</P>
<P>Here's an example of a simple list using the <TT><UL></TT> tags for unordered
lists:</P>
<PRE><FONT COLOR="#0066FF"><HTML>
<HEAD>
<TITLE> This is my Web Page! Welcome! </TITLE></HEAD>
<BODY>
<H1> This is a list of some books I have written. </H1>
Here are the books I wrote on last summer's vacation.
<UL>
<LI> Mosquitos Bug me
<LI> Fun with Bears
<LI> What to eat when you have no food
<LI> Why is it raining on my vacation?
<LI> Getting lost in three easy lessons
</LI>
</UL>
</BODY>
</HTML>
</FONT></PRE>
<P>An unordered list is like a normal list, except that it has bullets and is not
marked by any special numbering scheme. This code is shown in a browser in Figure
53.7, in which you can see the way the bullets line up and the list is presented.
<H6></H6>
<P><A NAME="Heading16<A HREF="../art/53/53lnx07.jpg"><FONT COLOR="#000077">FIGURE
53.7.</FONT></A><FONT COLOR="#000077"><I> </I></FONT><I>An unordered list in HTML.</I></P>
<P>The same code could be written with <TT><OL></TT> and <TT></OL></TT>
tags for an ordered list. An ordered list has numbers in front of the items, as shown
in Figure 53.8. This is the same code as shown previously, except that we changed
the <TT><UL></TT> tags to <TT><OL></TT> tags.
<H6></H6>
<P><A NAME="Heading17<A HREF="../art/53/53lnx08.jpg"><FONT COLOR="#000077">FIGURE
53.8.</FONT></A><FONT COLOR="#000077"> </FONT><I>An ordered list uses numbers rather
than bullets.</I>
<H3 ALIGN="CENTER"><A NAME="Heading18<FONT COLOR="#000077">Changing Character
Appearances</FONT></H3>
<P>Character tags can be used to change the appearance of text on the screen. There
are a few character tags in HTML, including styles (such as italics and boldface)
and logical (which indicate emphasis, code, or other types of text). Forcing character
type changes with style tags is not usually a good idea because different browsers
might not present the text the way you want to. You can use them, however, if you
know that your server will be used only with a particular type of browser and if
you know how the text will look on that browser.</P>
<P>Logical tags are a much better choice because browsers can implement them across
platforms. They let the individual browser decide how italics, for example, will
look. For that reason, we'll concentrate on logical tags; you should use them when
you can. Eight logical tags are in general use:
<UL>
<LI><TT><CITE></TT> a citation
<P>
<LI><TT><CODE></TT> code sample (Courier font)
<P>
<LI><TT><DFN></TT> a definition
<P>
<LI><TT><EM></TT> emphasis, usually italics
<P>
<LI><TT><KBD></TT> keyboard input to be typed by the user
<P>
<LI><TT><SAMP></TT> sample text, much like <TT><CODE></TT>
<P>
<LI><TT><STRONG></TT> strong emphasis, usually boldface
<P>
<LI><TT><VAR></TT> a variable name to be displayed as italics or underlined
(usually in code)
</UL>
<P>The following code shows an example of the use of some of these styles, and the
resultant Web page is shown in Figure 53.9.</P>
<PRE><FONT COLOR="#0066FF"><HTML>
<HEAD>
<TITLE> This is my Web Page! Welcome! </TITLE></HEAD>
<BODY>
<H1> This is an H1. </H1>
<P> This is a sample entry that should be <EM> emphasized using EM</EM> and with
the <STRONG> use of Strong </STRONG> emphasis.
</P>
</BODY>
</HTML>
</FONT></PRE>
<P>As you can see, this browser (Mosaic) interprets the <TT><EM></TT> tag to
be italics and the <TT><STRONG></TT> tag to be bold. Most browsers perform
this conversion, but other tags might look different with other browsers.</P>
<P>If you want to force character tags, you can do so with <TT><B></TT> and
<TT></B></TT> for boldface, <TT><I></TT> and <TT></I></TT> for
italics, and <TT><TT></TT> and <TT></TT></TT> for typewriter monospaced
font (code).
<H6></H6>
<P><A NAME="Heading19<A HREF="../art/53/53lnx09.jpg"><FONT COLOR="#000077">FIGURE
53.9.</FONT></A><FONT COLOR="#000077"> </FONT><I>The use of logical character tags
changes the way text appears.</I>
<H3 ALIGN="CENTER"><A NAME="Heading20<FONT COLOR="#000077">A Few Other Tags</FONT></H3>
<H3 ALIGN="CENTER"><FONT COLOR="#000077"></FONT></H3>
<P>To wrap up, a few other tags are useful in general Web page production. The first
is the <TT><PRE></TT> tag, which means the contents between the tags are preformatted
and should be left alone. Between the <TT><PRE></TT> and the <TT></PRE></TT>,
whitespace is important. Use of the <TT><PRE></TT> tag lets you preformat tables
or other content exactly as you want it (subject to wrapping rules in the browser).
For example, the following code has a <TT>PRE</TT> section in it:</P>
<PRE><FONT COLOR="#0066FF"><HTML>
<HEAD>
<TITLE> This is my Web Page! Welcome! </TITLE></HEAD>
<BODY>
<H1> This is an H1. </H1>
<P> This is a sample entry that should be <EM> emphasized using EM</EM> and with
the <STRONG> use of Strong </STRONG> emphasis. </P>
<PRE>
This is preformatted
text that should appear
exactly like this in the Browser
</PRE>
</BODY>
</HTML>
</FONT></PRE>
<P>As you can see in Figure 53.10, the spacing of the <TT>PRE</TT> material is retained,
and even the text font is the same as the source (Courier).
<H6></H6>
<P><A NAME="Heading21<A HREF="../art/53/53lnx10.jpg"><FONT COLOR="#000077">FIGURE
53.10.</FONT></A><FONT COLOR="#000077"> </FONT><I>The <TT>PRE</TT> tags let you preformat
text.</I></P>
<P>Another tag that is handy is simple. The <TT><HR></TT> tag creates a horizontal
rule across the page. For example, the preceding code can be enhanced with a couple
of <TT><HR></TT> tags like this:</P>
<PRE><FONT COLOR="#0066FF"><HTML>
<HEAD>
<TITLE> This is my Web Page! Welcome! </TITLE></HEAD>
<BODY>
<H1> This is an H1. </H1>
<P> This is a sample entry that should be <EM> emphasized using EM</EM> and with
the <STRONG> use of Strong </STRONG> emphasis. </P>
<HR>
<PRE>
This is preformatted
text that should appear
exactly like this in the Browser
</PRE> <HR>
</P>
</BODY>
</HTML>
</FONT></PRE>
<P>As you can see in Figure 53.11, two horizontal rules now appear on the page. The
exact appearance of the rule might change with browsers, but the overall effect is
to put a divider on the page.
<H6></H6>
<P><A NAME="Heading22<A HREF="../art/53/53lnx11.jpg"><FONT COLOR="#000077">FIGURE
53.11.</FONT></A><FONT COLOR="#000077"><I> </I></FONT><I>Use <TT><HR></TT>
to draw horizontal rules across the page.</I>
<H3 ALIGN="CENTER"><A NAME="Heading23<FONT COLOR="#000077">Summary</FONT></H3>
<H3 ALIGN="CENTER"><FONT COLOR="#000077"></FONT></H3>
<P>Many more HTML tags are available to you, but they are used for special items
such as tables, graphics, and other add-ins. As we mentioned at the start, this chapter
is designed to just give you a quick introduction to HTML, not to teach you everything
there is to know. As you have seen, though, HTML is a fairly simple language to work
with, and you should have a lot of fun designing your own Web pages.
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -