The <Form> Element
HTML forms are used to collect information from the user.
Forms are defined using the <form> element, with its opening and closing tags:
Use the action attribute to point to a webpage that will load after the user submits the form.
The method and name Attributes
The method attribute specifies the HTTP method (GET or POST) to be used when forms are submitted (see below for description):
To take in user input, you need the corresponding form elements, such as text fields. The <input> element has many variations, depending on the type attribute. It can be a text, password, radio, URL, submit, etc.
The example below shows a form requesting a username and password:
<input type=“text“ name=“username” /><br />
<input type=“password“ name=“password” />
If we change the input type to radio, it allows the user select only one of a number of choices:
<input type=“radio“ name=“gender” value=“female“ /> Female <br />
The type “checkbox” allows the user to select more than one option:
<input type=“checkbox“ name=“gender” value=“2” /> Female <br />
The submit button submits a form to its action attribute:
CLICK ON THE BUTTON BELOW TO GO TO THE HTML MAIN COURSE PAGE.
© License: All Rights Reserved
CONTACT HOLLA TECH – LEARN SUPPORT