Summary of HTML form tags and selected attributes

Tags

Tag Usage <form> define a form <textarea> define an area for multiline input with scrollbars <select> define choices for a selection list <input> define user input elements of various types, including: text, checkbox, radio buttons, password, submit, and reset

Explanations

<form> tags surround the entire form definition.
attributes include: action = "<url>" the url of the program which will process the input from the form method = "post" or "get" (determines how input will be passed to the server; generally post) <textarea> attributes include: name = string, the name of the variable passed to the server cols = n, the width of the text area rows = n, the height of the text area align = left, right, middle, top, or bottom The textarea ends with a </textarea> tag. <select> attributes include: name = string, the name of the variable passed to the server size = n, the number of list elements to display at one time multiple, indicates that more than one item may be selected The optional items to be selected are defined with the <option> tag: <option> string, the optional item One of the <option>s may have a selected attribute, indicating that it should be the default choice. The list of options is terminated with a </select> tag. The <input> tag has several attributes. The most important is the type attribute, values of which include text, checkbox, radio, password, reset, and submit: <input type = text name = string [value = string maxlength = n size = n] > <input type = checkbox name = string value = string [checked]> <input type = radio name = string value = string [checked]> (you need separate <input radio> tags for each choice and all must have the same name) <input type = password name = string [maxlength = n size = n] > (a password is like a text field, but it displays only *s) <input type = reset [value = string]> <input type = submit [name = string value = string]>

Note that the name attribute specifies the name of the variable that will be passed back to the program at the server. The value attribute specifies a value that will be passed back (for instance yes might be the value of the attribute married).

The checked attribute states which value will be checked off as the default on the form, and size and maxlength state give the length of the field and the maximum number of characters that may be input.

The attributes in [square brackets] are optional.

The names and values of the form elements are passed to the program at the server when the submit button is clicked. That program can do whatever you wish with the form input -- store it in a file or database, compute something based on the values in the form, look up an entry in a database, etc. The program may be written in any language. When it is written in an interpreted language like Perl, VB Script or Java Script, it is often referred to as a "script" rather than a "program." Note that it can be any executable program -- even a DOS bat file.

For tutorial material on forms and several examples, see: http://www.ncsa.uiuc.edu/SDG/Software/Mosaic/Docs/fill-out-forms/overview.html.


Disclaimer: The views and opinions expressed on unofficial pages of California State University, Dominguez Hills faculty, staff or students are strictly those of the page authors. The content of these pages has not been reviewed or approved by California State University, Dominguez Hills.