We introduce HTML, the markup language behind virtually every page of the World Wide Web. A sound knowledge of HTML provides an excellent foundation for the Ajax applications discussed in later lessons.
It wouldn’t be appropriate to try to give an exhaustive account of HTML (Hypertext Markup Language)—or, indeed, any of the other component technologies of Ajax. Instead we’ll review the fundamental principles and give some code examples to illustrate them, paying particular attention to the subjects that will become relevant when we start to develop Ajax applications.
What Is HTML?
The World Wide Web is constructed from many millions of individual pages, and those pages are, in general, written in Hypertext Markup Language, better known as HTML. That name gives away a lot of information about the nature of HTML.
We use it to mark up our text documents so that web browsers know how to display them and to define hypertext links within them to provide navigation within or between them.
Anyone who (like me) can remember the old pre-WYSIWYG word processing programs will already be familiar with text markup. Most of these old applications required that special characters be placed at the beginning and end of sections of text that you wanted to be displayed as (for instance) bold, italic, or underlined text.
What Tools Are Needed to Write HTML?
Because the elements used in HTML markup employ only ordinary keyboard characters, all you really need is a good text editor to construct HTML pages. Many are available, and most operating systems have at least one such program already installed. If you’re using some version of Windows, for example, the built-in Notepad application works just fine, or you can use Text Edit on Macs.
Our First HTML Document Introducing
Let’s jump right in and create a simple HTML document. Open Notepad (or whatever editor you’ve chosen to use) and enter the text shown in Listing The HTML markup elements (often referred to as tags) are the character strings enclosed by < and >.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01
<title>A Simple HTML Document</title>
<h1>My HTML Page</h1>
Welcome to my first page written in HTML.<br />
This is simply a text document with HTML markup to show some
words in <b>bold</b> and some other words in <i>italics</i>.
Now save the document somewhere on your computer, giving it the name testpage.html.If you now load that page into your favorite browser, such as Internet Explorer or Firefox, you should see something like the window displayed in figure.
Our test document displayed in internet explorer