Preformatted Text


Sometimes you don't want a block of text to be filled and justified like a paragraph.

Sometimes you may want to keep all the spaces and returns exactly as they are, as in a table like this, where you want everything to properly display in columns:

                                                                   
Date         Holiday                                                    
                                                                        
Oct 31       Halloween                                                  
Dec 25       Christmas                                                  
Jan 1        New Year's Day                                             

(Press the \ key to view the HTML source.)

This is the same text, without using the tag for preformatted text:

Date Holiday Oct 31 Halloween Dec 25 Christmas Jan 1 New Year's Day


Using preformatted text tags is an easy way to display large tables like the spreadsheet below:.

1995 Shipments From Southern Ports (tonnes)

                                                                
FRUIT      Jan  Feb  Mar  Apr  May  Jun  Jul  Aug  Sep  Oct  Nov  Dec
                                                                     
Bananas     85   71  105   89   92  110   96   84   72   75   79   84
Grapes      17   19   16   11   12    9    8    9   12   14   17   16
Oranges    501  423  440  372  420  432  490  510  522  503  488  471
Figs         1    1    2    3    3    2    3    1    -    -    -    2
Dates        2    -    -    2    3    3    2    2    3    2    1    1
Lemons      11    8    9   10   11   13   11    9    8    7    6    9
Grapefruit 105   89   92  110   96   84   72   75   79   84   93  101

But what happened here? The mess below was a copy of the same spreadsheet. Press \ a few times to see the source code, and see if you can find out what is wrong...

1995 Shipments From Southern Ports (tonnes)

pre> FRUIT Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec Bananas 85 71 105 89 92 110 96 84 72 75 79 84 Grapes 17 19 16 11 12 9 8 9 12 14 17 16 Oranges 501 423 440 372 420 432 490 510 522 503 488 471 Figs 1 1 2 3 3 2 3 1 - - - 2 Dates 2 - - 2 3 3 2 2 3 2 1 1 Lemons 11 8 9 10 11 13 11 9 8 7 6 9 Grapefruit 105 89 92 110 96 84 72 75 79 84 93 101

Didn't find it? Study the tags carefully...

Using preformatted text is an easy way to display a table in HTML. Just insert a <pre> before the table text and a </pre> after it.


[next: Special Characters] [previous] [contents]

Last modified 1996/04/27 22:59:18 GMT by helpdoc