Web pages are created with a text editor or word processor but are meant to be viewed with multiple browsers on multiple platforms. To be accessible to all of these different programs, Web pages are saved in a universal "text-only" formatwithout any proprietary formatting that a word processor might otherwise apply.
So that browsers (and servers) recognize Web pages and know to interpret the markup they contain, as well as distinguish them from plain text files that are not Web pages, Web page files also have the .htm or .html extension.
Because of that extension, a Web page's icon matches the system's default browser and not the word processor with which the file was written. Indeed, when you double-click a Web page file, it is opened in a browser, not a word processor. This is great for Web surfers, but it adds an extra step to editing Web pages (see page 50).
In short, when you save your Web page, you must save it in text-only format with either the .htm or .html extension.
Figure 2.5. An Excel worksheet has the .xlsx extension and is identified with the Excel icon (top). If you double-click it, it is displayed in Excel. A Web page file, no matter the word processor you create it with, has the .htm or .html extension but is identified with the default browser's icon. If you double-click it, it is displayed with your default browser (not the word processor).
To save your Web page:
Once you've created your Web page, choose File > Save As from your word processor (Figure 2.6).
Figure 2.6. Choose File > Save As from your word processor or text editor.
In the dialog box that appears, choose Plain Text or Text Document (or however your program words it) for the format.
Give the document the .htm or .html extension. (This is very important!)
Choose the folder in which to save the Web page.
Figure 2.7. In WordPad for Windows, give your file a name with the .htm or .html extension, choose Text Documents next to Save as type, and then click Save.
Figure 2.8. In TextEdit for Macintosh, give your file a name, choose a location, and click Save.
It doesn't matter whether you use .htm or .html (unless you're still on Windows 3.1! In that case, use .htm.) However, consistency will make it easier to remember your URLs later.
Some word processors (like Microsoft Word and Corel WordPerfect to name a few) offer a "Save as HTML" or "Save as Web page" option. Don't touch it! That option is for folks who want to create a Web page from a word processing document without learning HTML and it completely messes up hand-written code (see page 48).
Some text editors on Windows annoyingly add their default extension to your file name, even if you've already specified .htm or .html. Your file, now named webpage.html.txt won't be properly viewed in a browser. To make matters worse, Windows often hides extensions on the Desktop so that the problem is not completely obvious, especially to the uninitiated. There are two solutions. The first is to enclose your file name in double quotes when you save your document. This should keep the extra extension from being added. Next, you can display the extensions on the Desktop (Figure 2.9) and then select the offending extension and eliminate it. For details, see my Web site (see page 26).
Figure 2.9. On Windows computers, choose Tools > Folder Options to view this dialog box. Click the View tab and scroll down until you see Hide extensions for known file types. Make sure it is unchecked if you want to be able to see a file's extension (like .html) on the Desktop.
When you choose a text-only format, your file is usually saved with your system's default character encoding. If you want to create Web pages in another encoding (perhaps to include special symbols or text in other languages), you'll have to use a text editor that lets you choose the encoding (Figure 2.10). For more details, see Chapter 21, Symbols and Non-English Characters.
Figure 2.10. Many word processors, like the excellent BBEdit shown, let you choose the encoding for your file, so that you can save symbols and characters from different languages in the same document. BBEdit, as of version 7, automatically saves your file with the same encoding as you will declare in your document a little later on (page 59, to be exact). It's a lovely feature!