Unfortunately when the HTML for forms was being designed consistency was not a high priority. You will find that most form-specific tags are <input> tags, but there are several notable exceptions.
The main points to remember about forms are as follows:
a form starts with a
<form>tag and closes with a matching</form>tag. Form elements (text fields, drop-down menus, etc) are only valid between the opening and closing tag in XHTML. In HTML5 you may put a form element, such as an input, anywhere on the page, with or without a surroundingformtag.The
formtag has two attributes that are typically added:methodandaction.A form’s
methodis the way the submitted data is passed to whatever will be processing it (a CGI script, a PHP script, etc). Ninety percent of the time this method will bepost. Alternatively, thegetmethod appends the data to the URL itself when it is submitted, which is obviously less secure (but helpful, if you are interested in debugging a form or bookmarking a page created through a form decision).The
actionattribute of the form tag tells the form where to submit its data to. If a CGI script written in Perl was processing the data, theactionattribute would typically be set to something likecgi-bin/form.pl. If a PHP script, it would be something likeformhandler.php.
The first step in creating our form is the opening and closing <form> tags, with the correct attributes:
- <form method="post" action="formhandler.php">
- </form>
XHTML requires a fieldset tag immediately inside the form tag. fieldset is a container element inside the form. Think of filling out your tax form at the end of each year: each major section of the form (personal information, employer, income) is divided into a seperate box. fieldset is that box in the context of a form. A form may contain multiple fieldsets.
Immediately inside the fieldset you should enter a <legend> tag, with appropriate content. The <legend> is essentially the label for the entire fieldset, and typically indicates the purpose of that section. (“Personal information”, “Mailing Address”, “Billing Info”, etc).
fieldset is optional in HTML5, but it is a good idea to use it.
so we don't need the jQuery minimum length anymore:) cool!


