Creating HTML by Hand

HTML is basically nothing but plain American Standard Code for Information Interchange (ASCII) text in which certain characters have special meaning. These character sequences are known as HTML tags, and most are enclosed in angle brackets (<>). For instance, Listing 23.1 shows a short HTML file.

Listing 23.1: A Sample HTML File_

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

A"http://www.w3.org/TR/html4/loose.dtd">

<TITLE>Sample Web Page</TITLE> </HEAD>

<BODY BGCOLOR="#FFFFFF" TEXT="#000000"> <P>This is a sample web page. It can include features such as <A HREF="http://www.threeroomco.com/sample/">links</A>.</P> </BODY></HTML>

Most tags come in pairs. The first begins a formatting feature and the second ends it. The second tag is named like the first, but the name is preceded by a slash (/), as in <P> to start a paragraph and </P> to end it. Tags are not case sensitive. The tags demonstrated in Listing 23.1 include:

<!DOCTYPE> Most HTML files begin with a line such as the first line of Listing 23.1, which identifies the version of the HTML standard that the file follows. Most HTML editors give you several choices of document type. For simple pages, the document type isn't very important, so you should use whatever is the default. This tag has no matching closing tag.

<HTML> The actual HTML is enclosed within an <HTML> tag. Normally, the closing </HTML> tag signifies the end of the file. (Some HTML editors create incorrect tag nesting order, though, so sometimes closing tags for features within the file come after the </HTML> tag.)

<HEAD> An HTML header defines certain features of the file. The header isn't displayed in the browser's window, although parts of it may be accessible from the browser or displayed in the title bar.

<TITLE> The <TITLE> tag appears within the header and gives a title to the page. Many browsers display the title in the browser's window. When users add pages to their bookmarks, the pages' titles are the default text for accessing the pages.

<BODY> The bulk of the web page begins with the <BODY> tag, which closely follows the closing </HEAD> tag. Information within the body may be displayed in the reader's web browser window. Listing 23.1's <BODY> tag includes options within it to set the text and background colors. This example uses numeric color codes for white background and black text, but you can use name codes for common colors if you prefer.

<P> The <P> tag delineates a paragraph. Because web browsers ignore line breaks, these tags are necessary to mark where one paragraph begins and another ends.

<A HREF> This tag denotes an HTML link—a hypertext reference to another web page, an FTP site, an e-mail address, or the like, expressed as a URI. The text within quotes in the opening tag (http://www.threeroomco.com/sample in Listing 23.1) is hidden from the reader. The text between the opening and closing tags (links in Listing

23.1) typically appears in color, and it is often underlined, to signify that it's a link.

You can generate web pages, albeit not very flashy ones, with knowledge of just a few tags. In fact, you may not need many more tags than Listing 23.1 uses if you just want to display paragraphs of plain text. In addition, though, there are tags to create bulleted and numbered lists, to embed graphics within web pages, to create tables, and so on.

Tip If you want to generate an effect but don't know how to achieve it, you can probably learn by examining the HTML for a page that uses the effect. Most web browsers include an option accessible as View O Page Source or something similar so that you can examine a web page's underlying HTML.

0 0

Post a comment