Previously, in this chapter, you learned how to change the appearance of text by using formatting
tags. For example, if you want the browser to display a word in boldface, you enclose the word
within start and end boldface tags (<b></b>) in the Web page HTML. Similarly, to move text down
one or more lines, you insert one or more <br> tags. Thus, when creating a Web page, you often use
one set of HTML tags to control how the text looks, and another set of tags to control the layout of
the text on the page. Unfortunately, when the Web browser displays the text, the browser ignores
multiple spaces and new lines you may have entered in the HTML document to space or align page
content,
You can, however use the start and end preformatted text tags (<pre></pre>) to combine both
format and layout functions in a single set of HTML tags. The start and end preformatted text tags
(<pre></pre>) tell the Web browser to use a fixed pitch font and to display onscreen all the spaces,
and new lines, the browser finds within the preformatted text in the Web page HTML. (To avoid
misaligned paragraph text in the browser window, uses spaces and not the TAB key to line things up,
because not all browsers interpret the TAB key the same way.)
You might use preformatted text to display such things as program listings and recipes.
Figure 1-23, for example, shows a Web page with preformatted text.
Normally, you use preformatted text when you want to control the length of each line of text and
the spacing of the words within a line. Unfortunately, you cannot use <img> tags to insert pictures, or
<object> tags to insert ActiveX controls or Java applets within preformatted text. Although the start and
end preformatted text tags (<pre></pre>) let you control the placement of text, you must use HTML
tables or CSS rules to control the location of elements other than text.
0 comments:
Post a Comment