About Text-Only Files

Let's pause for a moment and consider file formats.

Most of us are familiar with word-processing programs such as Microsoft Word. When you save a document in Word, the file you create contains not only the text of your document, but also lots of extra information, such as what fonts to use, the size of your type, what portions of text are in bold or italic, and so forth.

By default, the file is encoded in a special format peculiar to Microsoft Word, which may be unreadable to other programs, giving rise to many a frustrating situation.

However, Word does give you some other options. (Just choose 'Save As...' instead of 'Save' under the 'File' menu. You'll see a dialog box which gives you the option of selecting other file formats.) You can save your Word document as a WordPerfect document, for example. You can also save it as a text-only document.

As the name implies, a text-only file contains only the text of a document, without any special formatting. Here's an example: a poem by a famous author. (Please look at it now, then use your "Back" button to return to this page.)

How HTML handles text

Did you look at the poem? Good. As you saw, there's nothing there but text (with line-breaks) and spaces. There's none of the special formatting we're used to seeing. There's no bold or italic, no variation in typeface or size, so special colors, no images -- nothing but plain old text. Some people refer to this no-frills presentation as plaintext.

If you looked at the address of the page, you may have noticed that the file name (poem.txt) ends with a three-letter extension (txt). Those three letters tell the server how to send the file to your browser. In essence, the server instructs your browser to interpret it as a text-only file. That's very important, as we'll see in a moment.

(You had to use the "Back" button on your browser to return to this page because I couldn't put a link there. It's not hypertext.)

Now let's play a trick on your Web browser. Let's look at a copy of that exact same text-only file -- only this file has been given a slightly different name. Instead of ending with the txt extention, it ends with html. This tells the server to advise your browser to interpret the file as HTML.

Of course, it's not HTML -- it's a text-only file. But we're fooling your browser.

Take a look at the poem, notice the difference, then use your back button to return to this page.

You should have noticed a distinct difference. This is how text is handled in HTML by default. Unless there are instructions to the contrary, line breaks and extra spaces are totally ignored.


| Introduction to HTML | Tutorials |