HTML - Form element

> (World Wide) Web - (W3|WWW) > HyperText markup Language (HTML)

1 - About

The form element represents a user-submittable form.

When parsed as HTML, a form element's start tag will imply a p element's end tag just before.

Forms element contains input element (Checkbox, …).


3 - State

Form elements such as <input>, <textarea>, and <select> typically maintain their own state (attribute value) and update it based on user input.

4 - Data Control

  • Client Side: JavaScript function
  • Server Side: The server gets the data and return the result (slow as you need two http call).

5 - Security

The biggest security problem with forms is the fact that an HTML forms can be submitted to other origins.

6 - Example

First name: <input type="text" name="firstname" value="">
Last name:  <input type="text" name="lastname" value="">

7 - DOM Accessors

The document attribute document.forms return an HTMLCollection of the form elements in the Document.