JavaScript by Example (2nd Edition)
In order to write Web pages, you must learn at least some of what makes up the HTML language. There are volumes written on this subject. Here we will cover just enough to introduce you to HTML and give you the basics so that you can write some simple dynamic pages with forms and CGI scripts. See Appendix B for a succinct tutorial on HTML. As previously stated, Web pages are written as ASCII text files in HTML. HTML consists of a set of instructions called tags that tell your Web browser how to display the text in the page. [2] When you type in the URL or click on a hyperlink in a page, the browser (client) communicates to the server that it needs a file and the file is sent back to the browser. The file contains HTML content that may consist of plain text, images, audio, video, and hyperlinks . It's the browser's job to interpret the HTML tags and display the formatted page on your screen. (To look at the source file for a Web page, you can use the View Document menu under View in the Netscape browser, or using Internet Explorer select the View menu and then select Source to see the HTML tags used to produce the page.) [2] If you have ever used the UNIX programs nroff and troff for formatting text, you'll immediately recognize the tags used for formatting with HTML. Creating Tags
The HTML source file can be created with any text editor. Its name ends in . html or . htm to indicate it is an HTML file. The HTML tags that describe the way the document looks are enclosed in angle brackets < >. The tags are easy to read. If you want to create a title, for example, the tag instruction is enclosed in brackets and the actual text for the title is sandwiched between the marker that starts the instruction, <TITLE> , and the tag that ends the instruction, </TITLE> . The following line is called a TITLE element , consisting of the <TITLE> start tag, the enclosed text, and the </TITLE> end tag. A tag may also have attributes to further describe its function. For example, a text input area may allow a specified number of rows and columns , or an image may be aligned and centered at the top of the page. The elements and attributes are case-insensitive.
<TITLE>War and Peace</TITLE> When the browser sees this instruction, the title will be printed in the bar at the top of the browser's window as a title for the page. To put comments in the HTML document, the commented text is inserted between <!-- and --> . Because HTML is a structured language, there are rules about how to place the tags in a document. These rules are discussed below. A Simple HTML Document
The following HTML file is created in your favorite text editor and consists of a simple set of tagged elements. Example C.5
(The HTML Text File) 1 <HTML> 2 <HEAD> 3 <TITLE> Hyper Test </Title> 4 </HEAD> 5 <BODY> 6 <H1>Hello To You and Yours!</H1> 7 <H2 ALIGN="center">Welcome 8 </H2> 9 <P>Life is good. Today is <I>Friday.</I></P> 10 </BODY> 11 </HTML> EXPLANATION
Figure C.2. The HTML document from Example C.5, as displayed in Internet Explorer.
Table C.4. Simple HTML tags and what they do.
|