HTML Basics[1]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

HTML Basics
Under the covers, the Web uses the Hypertext Markup Language (HTML) to send
information to Web browsers. This common markup language can be used by any
browser, on any computer. When you request a response from a Web page,
you're getting back an HTML stream, consisting of text "marked up" with
HTML elements as tags. If you're going to generate your own Web pages, you
need to have at least a basic understanding of HTML and how it renders in
the browser.

TIP

Yes, you can get by without really understanding anything about HTML, and
our guess is that most readers already have a reasonable grasp of HTML.
However, a basic knowledge of HTML can be important, because ASP.NET
generates HTML both at design time and at runtime, and your development
experience will go more smoothly if you're comfortable with HTML.



HTML has only a handful of basic tags that you need to learn in order to
create just about any Web site you want. Most of these tags are very simple
to use. The following subsections introduce some of the more common tags
you will encounter.

HTML Elements
HTML provides a huge list of elements as well as attributes that describe
those elements. We're going to cover a tiny portion of the available HTML
functionality here, mostly so you'll recognize the HTML elements used
throughout the book. The intent here is definitely not to provide an HTML
primer, but just to make sure we're all starting at the same place. For
more information on HTML, consult the appropriate reference materials on
that topic.

TIP

HTML isn't case sensitive. You'll note in the examples that the various
elements are sometimes in uppercase letters, and other times in lowercase
letters. You'll see HTML formatted both ways. Although HTML accepts
mixed-case elements (for example, <LI></li>), other similar markup
languages (such as XML) do not. Don't mix cases like this, or sooner or
later it will bite you back.



Hyperlink
The hyperlink provides the main form of navigation on a typical Web page. A
hyperlink typically appears as a highlighted word or group of words.
Clicking the hyperlink makes a request to a particular Web server, which
responds with the requested page.

To insert a hyperlink, you use text such as this:

<a href="Page to load">Text to display</a>

Note the matching begin and end tags (<a> and </a>) and the attribute
(href="Page to load") that's included within the opening tag. Any element
can contain one or more attributes梚n this case, there's only the one href
attribute.

The following example, Main.htm, contains a number of hyperlinks. You'll
find this example in the InternetBasics folder, and you can either load it
into a text editor to see its source, shown in Listing 5.1, or double-click
to load it directly into a browser.

Listing 5.1 The Contents of Main.htm
<HTML>
<BODY>
<H3>Hyperlink</H3>

<a href="UnorderedList.htm">Unordered List</a><br>
<a href="OrderedList.htm">Ordered List</a><br>
<p>
<a href="Select.htm">Select</a><br>
<a href="Table.htm">Table</a><br>
<a href="Input.htm">Input</a><br>
</p>

</BODY>
</HTML>

Line Break
HTML output generally flows from left to right, top to bottom through a
page (this is generally called flow layout). If you want to insert a line
break yourself, you can insert the <br> tag into the document. Unlike most
HTML tags, the <br> tag doesn't require an ending tag. You can see the use
of this tag in the hyperlink example earlier.

NOTE

In order to insert a paragraph break, add a <p> element to your document.
The sample page, Main.htm, uses a <p> element to break the information into
paragraph groupings.



Bulleted List
To create a bulleted list of items, use the <UL> tag. In between the <UL>
and </UL> tags, use the <LI> and </LI> tags to create each individual list
item. The <LI> tag automatically adds a line break after each item.

To try out this sample page (see Listing 5.2), which includes an unordered
list, locate UnorderedList.htm in the InternetBasics folder.

Listing 5.2 Contents of UnorderedList.htm
<HTML>
<BODY>
<H3>Unordered list</H3>

<UL>
<LI>Arizona</LI>
<LI>California</LI>
<LI>Nevada</LI>
</UL>

本文关键:HTML Basics
  相关方案
Google
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top