HTML and CSS Reference
In-Depth Information
<option value="brie">Brie</option>
The preceding markup would render as shown in Figure 4-22 .
Figure 4-22. A select menu organized with multiple optgroup elements
The optgroup element is a clear example of using the right tag for the right job. A
benefit of using optgroup elements to divide your option elements is that the op-
tgroup label cannot be selected, nor can its value be submitted as data, whereas in the
former example the page author would either have to live with erroneous submissions or
provide a client- or server-side validator to ensure such dividers had not been submitted.
Additionally, the optgroup element has a Boolean disabled attribute, which can
be used to disable whole groups of option elements, if required.
Text boxes
The textarea element is similar in some ways to the text input element, but it al-
lows multiple lines of input rather than just one. It uses a pair of attributes, cols and
r ows , to control its size, and instead of using a value attribute to preset any textual
content, it uses the content of the element itself. It's a container element, rather than a
self-closing empty element.
The following code creates a textarea that is 20 columns wide and 5 rows high (a
scrollbar will appear if the input exceeds the visible area).
Search WWH ::

Custom Search