HTML and CSS Reference
In-Depth Information
HTML Tags Used to Create Forms
Form statements start with the <form> tag and end with the </form> tag. The input
controls in a form are created using either HTML tags or attributes of HTML tags. For
example, the select and textarea controls are created using the HTML tags <select> and
<textarea>, respectively. Other input controls are created using attributes of HTML tags.
For example, the text boxes, check boxes, radio buttons, and Submit and Reset buttons all
are created using the type attribute of the <input /> tag. Table 6-2 lists the HTML tags
used to create the form in this chapter. Any combination of these elements can be used in
a Web page form.
Table 6-2 HTML Tags Used to Create Forms
Groups related controls on a form
Optionally used for readability
Creates a form that allows user input
Required when creating forms
<input />
Defines the controls used in the form, using a
variety of type attribute values
Required for input controls
Defines the caption that is displayed in the
grouping borders
Optionally used when using <ieldset> tags
Specifies a choice in a <select> tag
Required, one per choice
Creates a menu of choices from which a
visitor selects
Required for selection choices
Creates a multiple-line text input area
Required for longer text inputs that
appear on several lines
Attributes of HTML Tags Used to Create Forms
Many of the HTML tags used to create forms have several attributes. Table 6-3 lists
some of the HTML tags used to create forms, along with their main attributes and functions.
All tags and attributes are listed in Appendix A. HTML5 includes new attributes for the
<input /> tag. Many of these are not yet supported by browsers, however.
Table 6-3 Attributes and Functions of HTML Tags Used to Create Forms
• URL for action completed by the server
• HTTP method (post)
• Location at which the resource will be displayed
<input />
• Alternative text for an image control
• Sets a radio button or check box to a checked state (only one can be
• Disables a control
• Maximum number of characters that can be entered
• Name of the control
• Specifies that an element should be read-only; meaning not editable; can
be used with value attribute so text box or other input control has content
• Number of characters of an <input /> element that appear on the form
• Specifies the URL of an image to use as a submit button
• Type of input control (text, password, checkbox, radio, submit, reset, file,
hidden, image, button, among others)
• Value submitted if a control is selected (required for radio and checkbox
Search WWH ::

Custom Search