|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
The PRE element marks text to be displayed with a fixed-width typewriter font. In particular, the PRE environment preserves the line breaks and space characters of the original textthis is the only HTML element that does so. PRE is therefore useful for presenting text that has been formatted for a fixed-width character display, such as a plain text terminal or for presenting program code or HTML markup examples that should be presented with a fixed-width font. PRE supports the standard generic and event-handler attributes described earlier in this chapter. Note that the event handlers are only partially supported by Internet Explorer 4 and are not supported by Netscape Navigator 4. PRE content is restricted to inline elements, with the exception of those inline elements that affect character font size or spacing (BASEFONT, BIG, FONT, SMALL, SUP, and SUB) or that insert arbitrary data (APPLET, IMG, OBJECT). Most browsers will allow these forbidden inline elements inside PRE, but the behavior is unpredictable. An example of PRE is shown in Figures 6.15 and 6.16. Note the use of character highlighting. Character highlighting elements inside a PRE contribute zero character width. Netscape Navigator supports two additional attributes, to control the rendering of PRE content. These attributes are defined in the followingnote that these are nonstandard attributes and that equivalent formatting control is possible using style sheet instructions, as described in Chapter 7.
Figure 6.15 HTML example document illustrating the use of the PRE element. Figure 6.16 shows this document as displayed by the Netscape Navigator browser. <HTML> <HEAD> <TITLE> Example of the PRE Element </TITLE> </HEAD> <BODY> <H1 ALIGN=center> Example of the PRE Element</H1> <P ALIGN=center> <B><I>The PRE element is often used to include blocks of plain text. For example you can use it to include examples of typed code, such as the following extract from a C program:</I></B> <HR> <PRE> /* main program for fitting program */ extern int *sharv; static char boggle[100]; main (int argc, char *argv) double x_transpose, y_transpose, f_ack=2.3; { .... </PRE> <HR> <P> PRE is also useful for simple tables, as in: <PRE> Item Price Tax Total Category fileserver 10000 300 10300 <A HREF=cat_a.html>A</A> disk drive 900 30 930 <A HREF=cat_b.html>B</A> <STRONG>transmission</STRONG> 4400 110 4510 C <EM>fertilizer</EM> 5500 100 5600 F </PRE> The markup tags take up no space: if you delete everything alt the tags inside the <B>PRE</B>, you will see that all the columns line up. . </BODY> </HTML>
Fill-in FormsHTML 3.2 supported interactive forms via the FORM element and the special elements INPUT, SELECT, OPTION, and TEXTAREAthese four elements define a forms user input mechanisms and can only appear inside a FORM. The FORM element, in turn, specifies how the data collected by the form should be encoded and where the encoded data should be sent. Advanced FORMS: BUTTON, FIELDSET, LABEL, LEGEND, and OPTGROUPHTML 4 introduced five new form-content elementsBUTTON, FIELDSET, LABEL, LEGEND, and OPTGROUP, plus several new attributes, to support improved rendering of form content and better control over the input mechanisms. These elements are not supported by Netscape Navigator 4, but are partially supported by Internet Explorer 4. Since this chapter focuses on generally supported HTML markup, discussion of these newer elements is deferred to Chapter 7. Page Layout with INPUT ElementsA designer has little control over the look of these different form input elements: In general, the FONT element affects text-labeled input elements (TYPE=text, password, buttons with text labels, or TEXTAREA elements) in very different ways, depending on the browser, as illustrated in Figures 6.17 and 6.18. Both Netscape Navigator 3 and Internet Explorer 3/4 ignore FONT or other text-highlighting elements surrounding form input elements (although, for some strange reason, the SUP element works with Navigator 3). With Navigator 4, however, these elements do affect the characteristics of the input elements, as shown at the bottom of Figure 6.18note, however, that the browser miscalculates the size of the text input box when the FONT element changes the font face to a non-fixed-width font. Alternatively, a cascading style sheet can set some of the display properties. An example is shown in Figures 6.19 and 6.20, where CSS rules are used to change the font size, family, and text color of text input elements and INPUT buttons. There are still important differences between the Netscape Navigator 4 and Internet Explorer 4 rendering of these elements, as shown in Figure 6.20: Only Internet Explorer can change the text color on buttons, while both browsers have trouble determining the correct width for text input regions. Note also that the default font for text input regions (INPUT or TEXTAREA) is Arial for Internet Explorer and Courier for Netscape Navigator. FORM Element: Fill-in Forms
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |