Context Usually, it is used as a child of a <form> elemen t. If not,
then it should have specified the form attribute.
Content Can contain no < label> elements a nd no labelable form-
associated elem ents other than the on e that it labels.
Display
Inline
Attributes
for
With this attribute, authors indicate a form control element with which they want
to associate th e caption. The value of this attribute should be equal to the value of
the id attribute of the associated element. Alternatively, if there is no for attribute,
the association can be made by simply putting the form control element inside the
<label> element.
form
This attribute should be specified if a <label> element is located outside of any
<form> element. It shou ld be given the value of the id attribute of the <form> el-
ement to which it belongs. This attribute enables authors to pu t <label> elements
anywhere in the document.
Examples
<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name">
<label>Middle Name:
<input type="text" id="middle_name" name="middle_name">
</label>
<option>
Description Represents an item within a <select> ele ment.
Context
It can be used as a child of a <select> element.
Content
Can only contain text.
334 HTML Reference
HTML Reference
Attributes
label
Provides a caption for an element. If this attribute is not used, then it assume s the
value of the content of th e <option> element.
selected
This is a Boolean attribute a nd is specified without a value. If it is present, then the
option is initially put into the selected state.
value
Provides a value for an element. If this attribute is not used, then it assumes the value
of the content of the <option> element.
Examples
<!-- Offer to select one of the options with the Super King Size
Bed preselected. -->
<select name="select_a_bed">
<option value="compact">Compact Single Bed</option>
<option value="single">Single Bed</option>
<option value="compact_double">Compact Double Bed</option>
<option value="double">Double Bed</option>
<option value="king">King Size Bed</option>
<option value="super_king" selected>Super King Size Bed</option>
</select>
<!-- Offer to select any number of options. -->
<select size="3" name="order" multiple>
<option>Double Down</option>
<option>Pumpkin Spice Latte</option>
<option>Cherry Limeade</option>
<option>Beefy Crunch Burrito</option>
<option>Sweet Potato Fries</option>
</select>
<select>
Description
Represents a control for selecting between a set of possible
choices.
Content Zero or more <o ption> elements.
Display Inline
C.9. Forms 335
Attributes
form
This attribute connects a <se lect> elem ent with a sp ecific form, w hich thus bec omes
the <select> eleme nt’s owner. The value of the form attribute must be equal to the
value of the id attr ibute of the form. If this attribute is omitted, then the <select>
element must be a descendant of a <form> eleme nt.
multiple
This is a Boolean attribute a nd does not require a value. If it is present, then multiple
options can be selected at the same time. Multiple options can be selected by h olding
the Ctrl key and simultaneously click ing on desired options.
name
Specifies a name for a control, which is used at form submission.
size
This attribute gives the number of options that are visible at the same time. If the
multiple attribute is present, then the default value of the size attribute is 4 , other-
wise it is 1.
Examples
See the <option> examples on page 335.
<textarea>
Description
Represents a multi-line control for entering plain text.
Context
Usually, it is used as a descendant of a <form > element. If
not, then it should have specified the form attribute.
Content
It can contain character data.
Display Inline
Attributes
cols
The cols attribute is a non-negative integer specifying the expected maximum number
of ch aracters in a line. If this attribute is not specified, it defaults to 20.
336 HTML Reference
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.86.121