To ask the user for a specific piece of information within a form, use the <input /> tag. This tag must fall between the <form> and </form> tags, but it can be anywhere on the page in relation to text, images, and other HTML tags. For example, to ask for someone's name you could type the following: What's your first name? <input type="text" size="20" maxlength="30" name="firstname" /> What's your last name? <input type="text" size="20" maxlength="30" name="lastname" /> The type attribute indicates what type of form element to displaya simple one-line text entry box in this case. (Each element type is discussed individually in the following sections.) The size attribute indicates approximately how many characters wide the text input box should be. If you are using a proportionally spaced font, the width of the input will vary depending on what the user enters. If the input is too long to fit in the box, most web browsers will automatically scroll the text to the left. maxlength determines the number of characters the user is allowed to type into the text box. If someone tries to type beyond the specified length, the extra characters won't appear. You can specify a length that is longer, shorter, or the same as the physical size of the text box. size and maxlength are used only for type="text" because other input types (check boxes, radio buttons, and so on) have a fixed size.
|