P REFORMATTED TEXT
Most of the ti me, text in an HTML file is formatted based on the HTML tags used to mark up that text. As I mentioned in lesson 3, “introducing HTML and XHTML,” any extra white space (space, tabs, returns) that you pout in your text is stripped out by the browser.
The one exception to this rule in the preformatted text tag <pre>. Any white space that you out into text surrounded by the <pre> and </pre> tags is retained in the final output. With these tags, the spacing in the text in the HTML source is preserved when it’s displayed on the page.
The catch is that preformatted text usually is displayed (in graphical displays, at least) in a monospaced font such as courier. Preformatted text is excellent for displaying code examples in which you want the text formatted with spaces, you can use it for simple tables. However, the fact that the tables are presented in a monospaced font might make them less than ideal. (you’ll learn how to create real tables in lesson 8, “building tables”.) the following is an example of a table created with <pre>:
INPUT
<pre>
Diameter distance time to time to
(Miles) from sun orbit rotate
(Millions of Moles)
Mercury 3100 36 88 days 59 days
Venus 7700 67 225 days 244 days
Earth 7920 93 687 days 24 hrs 24 mins
Mars 4200 141 687 days 24 24 hrs 24 hrs
Jupiter 88640 483 11.9 years 9 hrs 350 hrs
Saturn 74500 886 29.5 years 1 0 hrs 39 min
Uranus 32000 1782 84 years 23 hrs
Pluto 1500 3670 165 days 15 hrs 48 minis
</pre>
Figure 6.4 shows how it looks in a browser.
No comments:
Post a Comment