When the Browser Displays the Code
Although you may be proud of your (X)HTML code, when you view your file with a browser, you want that code converted into a beautiful Web page, not displayed for all to see.
When the browser displays the code instead of the page:
Have you saved the file in text-only format (sometimes called "Text Document" or "Plain Text")? Sometimes, if you've saved the file previously as a, say, Word document, saving it as text-only isn't enough. You have to create a brand new document, copy and paste the code to that new document, and then save it as text-only.
Have you saved the file with an .htm or .html extension? You must (see page 46).
Have you begun the page with the proper DOCTYPE? (see page 56).
Do you shun Word's (or some other word processor's) "Save as Web Page" or "Save as HTML" command and the Web page format for saving files? That command, in all its incarnations, is only for converting regular text into Word's idea of a Web page (Figures 22.19 and 22.20). If you're writing your own code, this command will "code your code" (see page 48). Instead, choose Save As and then save the file in Text Document format with the .htm or .html extension.
19. This page, shown here in Internet Explorer, was created in Word by choosing Web Page as the format in which to save the file. Word "coded the code", making a Web page that shows the code instead of using it. I would bet it's not what you expected.
20. If you select View Source, you can see how Word coded the code, changing the angle brackets (< and >) to < and >, converting quotation marks to " and adding an incredible amount of superfluous junk.
Is Windows adding .txt extensions to the files you save as "page.html", creating something like "page.html.txt"? Find out by viewing file extensions in the folder. To avoid it, enclose the file name in double quotation marks in the Save As dialog box.