19.10 Groups of Controls

HTML 4.0 defines the FIELDSET element, with an associated LEGEND , that can be used to visually group controls within a form. Note that the FIELDSET element works only in Netscape 6 and later and Internet Explorer 6 and later.


Attributes: None.

This element is used as a container to enclose controls and, optionally , a LEGEND element. It has no attributes beyond the universal ones for style sheets, language, and so forth. Listing 19.14 gives an example, with the result shown in Figure 19-26.

Listing 19.14 Fieldset.html
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD>   <TITLE>Grouping Controls</TITLE> </HEAD> <BODY BGCOLOR="#FDF5E6"> <H2 ALIGN="CENTER">Grouping Controls</H2> <FORM ACTION="http://localhost:8088/SomeProgram">  <FIELDSET>   <LEGEND>Group One</LEGEND>  Field 1A: <INPUT TYPE="TEXT" NAME="field1A" VALUE="Field A"><BR> Field 1B: <INPUT TYPE="TEXT" NAME="field1B" VALUE="Field B"><BR> Field 1C: <INPUT TYPE="TEXT" NAME="field1C" VALUE="Field C"><BR>  </FIELDSET>   <FIELDSET>   <LEGEND ALIGN="RIGHT">Group Two</LEGEND>  Field 2A: <INPUT TYPE="TEXT" NAME="field2A" VALUE="Field A"><BR> Field 2B: <INPUT TYPE="TEXT" NAME="field2B" VALUE="Field B"><BR> Field 2C: <INPUT TYPE="TEXT" NAME="field2C" VALUE="Field C"><BR>  </FIELDSET>  </FORM> </BODY></HTML> 
Figure 19-26. The FIELDSET element lets you visually group related controls shown in Netscape 7.0.


HTML Element: <LEGEND> ... </LEGEND>

Attributes: ALIGN

This element places a label on the etched border that is drawn around the group of controls; it is legal only within an enclosing FIELDSET .


This attribute controls the position of the label. Legal values are TOP , BOTTOM , LEFT , and RIGHT , with TOP being the default. In Figure 19-26, the first group has the default legend alignment, and the second group stipulates ALIGN="RIGHT" . In HTML, style sheets are often a better way to control element alignment since they permit a single change to be propagated to multiple pages.

Core Servlets and JavaServer Pages (Vol. 1.Core Technologies)
Core Servlets and Javaserver Pages: Core Technologies, Vol. 1 (2nd Edition)
ISBN: 0130092290
EAN: 2147483647
Year: 2002
Pages: 194

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net