HTML and CSS Reference
In-Depth Information
associates a name with the data entered in that field when the data is sent to the server.
The rest of this section describes the different types of controls you can create using the
input element.
Creating Text Controls
Text controls enable you to gather information from a user in small quantities. This con-
trol type creates a single-line text input field in which users can type information, such as
their name or a search term.
To create a text input field, create an input element and choose text as the value for the
type attribute. Make sure to name your control so that the server script can process the
<label for=”petname”> Enter your pet's name </label>
<input type=”text” name=”petname” />
Figure 11.5 shows this text control, which tells the user what to type in.
A text entry field.
You can modify the appearance of text controls using the size attribute. Entering a num-
ber sets the width of the text control in characters:
<input type=“text” name=“petname” size=“15” />
To limit the number of characters a user can enter, add the maxlength attribute to the text
control. This doesn't affect the appearance of the field; it just prevents the user from
entering more characters than specified by this attribute. If users attempt to enter more
text, their web browsers will stop accepting input for that particular control:
<input type=“text” name=“petname” size=“15” maxlength=“15” />
Search WWH ::

Custom Search