HTML for forms and extended tags
Here's a summary of the tags that you'll need to use for creating forms on
your web pages, plus some of the common extensions to HTML that will be
supported by a range of browsers.
Form tags
- <form method=post action="URL">
- Define a form, the data from which will be passed to URL, which should be a
script, when the form is completed. 'method' can also be set to 'get',
but post is recommended.
- </form>
- End of form definition. Multiple forms can be present on a single page
- <input name="var_1"> or <input name="var_1"
type="text">
- Define a text entry field, the result of which will be stored in a
variable called var_1
- <input name="var_2" value="default">
- A text field, stored in var_2, with a default value of 'default'
- <input name="var_3" type="radio" value="val_1">
- Define a radio button, with results stored in var_3. This button
will return the value 'val_1' You can have as many tags as you like with the
same name, but with different values, and only one can be selected
- <input name="var_4 type="password">
- A text entry field, but the value typed in will not be displayed on the
screen
- <input name="var_5" type="checkbox">
- A simple checkbox, which will set var_5 to either 'on' or 'off'
depending on whether or not it's been checked
- <select name="var_6"> ... </select>
- Define a drop down list of options. Each <option> must
appear within the select tags
- <option>Option 1
- An option for a drop down selection list. The text 'Option 1' will appear
on the list
- <option selected>Option 2
- A pre-selected option on a drop down list
- <textarea name="var_6" rows=10 cols=30>...</textarea>
- Define a space for entering a large amount of text, to be stored in var_6.
The area will be 10 rows (lines) by 30 columns, though the text can be longer.
Default text can appear between the start and end tags.
- <input type="submit">
- A button to submit the completed for to the web server. If a 'value='
section is included, it will be used to label the button, which will otherwise
say 'Submit'
- <input type="reset">
- A button to reset the form, as if you had just loaded the page. The button
will normally be labelled 'Reset' unless the 'value=' section
is included.
Fields of type "password" and "text" can have an
additional option, 'size=' which limits the number of characters that
can be displayed in the field to that specified. The 'maxlength='
option specifies the maximum number of characters than can be entered.
Extensions to existing tags
- <body background="bg.gif">
- Use the file bg.gif as a background to the current document
- <img width=72 height=72>
- Specify the width and height of an image in a document. Percentages can
also be specified
![[ next ]](ng.gif)
![[ LAST ]](l.gif)
![[ PART 1 ]](p1.gif)
![[ PART 2 ]](p2.gif)
![[ Back to the tutorial front page ]](tutorlogo.gif)