home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book HomeWebmaster in a Nutshell, 3rd EditionSearch this book

6.2. The <input> Tag

Use the <input> tag to define any one of a number of common form elements, including text fields, multiple-choice lists, clickable images, and submission buttons. Although there are many attributes for this tag, only the type and name attributes are required for each element (only type for a submission button). Each type of input element uses only a subset of the allowed attributes. Additional <input> attributes may be required based on the specified form element.

You select the type of element to include in the form with the <input> tag's required type attribute and name the field (used during the form-submission process to the server) with the name attribute.

The most useful (as well as the most common) form-input element is the text-entry field. A text-entry field appears in the browser window as an empty box on one line and accepts a single line of user input that becomes the value of the element when the user submits the form to the server. To create a text entry field inside a form in your HTML document, set the type of the <input> form element to text. You must include a name attribute as well.

The size and maxlength attributes allow you to dictate the width, in characters, of the text-input display box and how many total characters to accept from the user, respectively. The default value for size is dependent on the browser; the default value for maxlength is unlimited.

A text-entry field is usually blank until the user types something into it. You may, however, specify an initial default value for the field with the value attribute.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.