Forms
Main html elements for making forms:
- form represents a document section containing interactive controls for submitting information to server
- input is used to create interactive controls in order to accept data from the user
- textarea represents a multi-line plain-text editing control, useful when you want to allow users to enter a sizeable amount of free-form text
- button represents a clickable button, which can be used in forms or anywhere in a document
How it works? When the user clicks the submit button, the browser collects data as "name1=value1&name2=value2" and sends it with the http request specified by the action attribute of form. Here namex is id of the input element and valuex is its value.
The following is a brief description of some of the attributes for input elements.
atribute | description |
---|---|
id, name | Name of element. The name attribute is obsolete, the id should be used or both. |
value | Value that will be send to the server. Can be changed by user. Format of value depend from type of value. |
requred | Define whether value can be empty or not. |
min, max | Define range of possible value. Can be used to input numbers, dates and time. |
form | id of the associated <form> element. It is used when the input element outside the <form> element. |