📄 ch53.htm
字号:
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<font face="Arial,Helvetica" size="-1" color="#006666">
<b>Linux</b></font><p>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<UL>
<LI><A HREF="#Heading1">- 53 -</A>
<UL>
<LI><A HREF="#Heading2">HTML Programming Basics</A>
<UL>
<LI><A HREF="#Heading3">What Is HTML?</A>
<LI><A HREF="#Heading4">What Does HTML Look Like?</A>
<UL>
<LI><A HREF="#Heading5">FIGURE 53.1.</A>
</UL>
<LI><A HREF="#Heading6">NOTE</A>
<LI><A HREF="#Heading7">Starting an HTML Document</A>
<UL>
<LI><A HREF="#Heading8">FIGURE 53.2.</A>
<LI><A HREF="#Heading9">FIGURE 53.3.</A>
<LI><A HREF="#Heading10">FIGURE 53.4.</A>
</UL>
<LI><A HREF="#Heading11">NOTE</A>
<UL>
<LI><A HREF="#Heading12">FIGURE 53.5.</A>
</UL>
<LI><A HREF="#Heading13">Links</A>
<UL>
<LI><A HREF="#Heading14">FIGURE 53.6.</A>
</UL>
<LI><A HREF="#Heading15">Lists</A>
<UL>
<LI><A HREF="#Heading16">FIGURE 53.7.</A>
<LI><A HREF="#Heading17">FIGURE 53.8.</A>
</UL>
<LI><A HREF="#Heading18">Changing Character Appearances</A>
<UL>
<LI><A HREF="#Heading19">FIGURE 53.9.</A>
</UL>
<LI><A HREF="#Heading20">A Few Other Tags</A>
<UL>
<LI><A HREF="#Heading21">FIGURE 53.10.</A>
<LI><A HREF="#Heading22">FIGURE 53.11.</A>
</UL>
<LI><A HREF="#Heading23">Summary</A>
</UL>
</UL>
</UL>
<P>
<HR SIZE="4">
<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 53 -</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">HTML Programming
Basics</FONT></H2>
<P>IN THIS CHAPTER</P>
<UL>
<LI>What Is HTML?
<P>
<LI>What Does HTML Look Like?
<P>
<LI>Starting an HTML Document
<P>
<LI>Links
<P>
<LI>Lists
<P>
<LI>Changing Character Appearances
</UL>
<P>n A Few Other Tags 987 Hypertext Markup Language (HTML) is the language used to
write World Wide Web pages. It is quite an easy language, and as several versions
have been introduced over the past few years, it has become quite powerful too. We
can't hope to teach you HTML in a single chapter in this book, but we can give you
an overview of the language and of how to use the basics to produce a simple Web
page or two. A lot of good books on HTML are out there, so if you want to become
very proficient in writing Web pages, we suggest you pick up one of them.</P>
<P>A lot of automated Web page production tools are available on the market, mostly
for Windows and Windows NT machines. These use a WYSIWYG editor to lay out a Web
page, then generate HTML code for you. With this type of tool, you don't need to
know much (if any) HTML. Not very many HTML generators are available for Linux, however.
On top of that, HTML is quite easy to learn, and anyone who is interested in setting
up a Web site for the Internet or an intranet should learn at least the basics. Several
tools are available for Linux that scan HTML code to make sure that it is syntactically
correct, but we won't bother using any in this chapter. If you want to find a syntax
checker, check out one of the Linux support sites, such as <TT>http://www.xnet.com</TT>,
which is a good starting place to find Linux software. Also, the Linux home site
of <TT>http://www.linux.org</TT> usually has information about available software.
<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">What Is HTML?</FONT></H3>
<P>We'll assume you already know what the World Wide Web (WWW) is. If you've seen
a Web page before, you have seen the results of HTML. HTML is the language used to
describe how the Web page will look when you access the site. The server transfers
the HTML instructions to your browser, which converts those HTML lines of code into
the text, images, and layouts you see on the page.</P>
<P>A Web browser is usually used to access HTML code, but other tools can carry out
the same function. Many kinds of browsers are out there, starting with the grandaddy
of them all, NCSA's Mosaic. Netscape's Navigator is the most widely used browser
right now, although Microsoft is slowly making inroads with its Internet Explorer.
Which browser you use doesn't matter, because all browsers do mostly the same job:
display the HTML code they receive from the server. A browser is almost always acting
as a client, requesting information from the server.</P>
<P>The HTML language is based on another language called SGML (Standard Generalized
Markup Language). SGML is used to describe the structure of a document and allow
for better migration from one documenting tool to another. HTML does not describe
how a page will look; it's not a page description language like PostScript. Instead,
HTML describes the structure of a document. It indicates which text is a heading,
which is the body of the document, and where pictures should go. But it does not
give explicit instructions on how the page will look; that's up to the browser.</P>
<P>Why use HTML? Primarily because it is a small language and therefore can transfer
instructions over a network quickly. HTML does have limitations because of its size,
but newer versions of the language are expanding the capabilities a little. The other
major advantage to HTML is one most people don't think about: it is device independent.
It doesn't matter which machine you run; a Web browser takes the same HTML code and
translates it for the platform. The browser is the part that is device dependent.
That means you can use HTML to write a Web page and not care which machine is used
to read it.
<H3 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">What Does HTML Look
Like?</FONT></H3>
<P>HTML code is pretty straightforward, as you will see. For the most part, it consists
of a bunch of "tags" that describe the beginning and ending of a structure
element (such as a heading, paragraph, picture, or table). For each element, there
should be a beginning and ending tab. A sample HTML page is shown in Figure 53.1.
Don't worry about understanding it all now; you will see this code built up in this
chapter. For now, you need to see only that there are beginning and ending tags around
each element in the structure. (All the screen shots used in this chapter are taken
from either a Windows 95 or a Windows 3.11 machine accessing the Linux server on
which we are writing the HTML code through an Ethernet network. The browser is NCSA's
Mosaic.)
<H6></H6>
<P><A NAME="Heading5<A HREF="../art/53/53lnx01.jpg"><FONT COLOR="#000077">FIGURE
53.1.</FONT></A><FONT COLOR="#000077"> </FONT><I>A simple example of HTML code.</I></P>
<P>A couple of important things to know about tags as we get started: they are case
insensitive (so you don't have to be careful about matching case), and they are almost
always paired into beginning and ending tags. The most common errors on Web pages
are mismatched or unterminated tags. In many cases, the Web page will appear OK,
but there might be severe formatting problems in some cases. A quick scan of your
HTML code will help solve these types of problems.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading6<FONT COLOR="#000077"><B>NOTE:</B> </FONT>Not all HTML tags
have a beginning and ending tag. A few are single ended, meaning they usually have
just a beginning. Some others are called containers because they hold extra information.
These are not always tagged at both ends.
<HR>
</DL>
<P>Tags are written in angle brackets. These brackets signal to the browser that
an HTML instruction is enclosed. A sample HTML code element looks like</P>
<PRE><FONT COLOR="#0066FF"><tag_name> text text text </tag_name>
</FONT></PRE>
<P>where <TT><</TT>tag_name<TT>></TT> and <TT><</TT>/tag_name<TT>></TT>
are the starting and ending tags for the text in the middle. The ending tag has the
same name as the starting tag, but is preceded by a slash to indicate the tag's conclusion.
The type of tag describes how the text will look. For example, if the tags are heading
tags, the text will appear larger than normal body text and might be in bold or highlighted
in some way.</P>
<P>How do you write HTML code? There are several ways to do it, the easiest being
to use any ASCII editor. Be sure not to save HTML documents in a proprietary format
like Word documents, because a Web browser can't understand anything but ASCII. Some
specialized HTML editors are available that feature pull-down lists of tags and preview
screens. These can be handy when you are working with very large Web pages, but for
most people a simple editor is more than enough to get started with.
<H3 ALIGN="CENTER"><A NAME="Heading7<FONT COLOR="#000077">Starting an HTML
Document</FONT></H3>
<P>The start of an HTML document usually begins with an instruction that identifies
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -