|
Writing HTML | About | FAQ | References | Tags | Lessons | previous | next |9. Preformatted TextHow do you display text where space, TABS and carriage return characters count? ObjectivesAfter this lesson you will be able to:
LessonNote: If you do not have the working documents from the previous lessons, download a copy now. In previous lessons we have seen that a web browser will ignore extraneous space characters, tabs, and carriage returns in your HTML files. However, there are some instances where it will be important to maintain these aspects of page layout. In this lesson, the example will be where we want to insert a table of text with aligned columns. The preformat tag instructs your web browser to display the text exactly as typed in the HTML document, including spaces, tabs, and carriage returns. A browser typically displays such text as a
type, meaning a font in which every character has the same width. Here is example of what the preformat does:
Without the <pre> and </pre> tags, the same HTML produce:
With the preformat tag, it helps if the text editor you are using can display in a monospaced font (such as "Courier" or "Monaco"); if not, you will have to count spaces when aligning text into columns (and you will mutter bad words under your breath). For our Volcano lesson, we want to add a table under the Introduction section that lists several well-known volcanoes, when they erupted, and the volume of erupted material. To do this:
Check Your WorkCompare your web page with a sample of how this document should appear. If your web page was different from the sample, review the text you entered in the text editor. If the columns are not aligned, then it is likely that you are missing or have too many space characters. ReviewReview topics for this lesson:
More InformationYou can still use HTML tags inside text that is marked by the preformat tag. For example we can add a hypertext link and some style tags that are within the <pre>...</pre> tags:
Independent PracticeAdd a table or chart to your HTML document using the preformat tag. Coming Next....Use special character sets to add some âccèñt to your web pages. GO TO.... | Lesson Index | previous: "HyperGraphics" | next: "Special Characters" |
Writing HTML: Lesson 9: Preformatted Text |