HTML
HTML Introduction
HTML Element
HTML Attributes
HTML Heading
HTML Paragraph
HTML Style
HTML Format
HTML Color
HTML Link
HTML Image
HTML Table
HTML List
HTML Symbols
HTML Emojis
HTML Forms
HTML Forms
An HTML form is used to collect user input. The user input is most often sent to a server for processing.
The <form> Element
The HTML <form> element is used to create an HTML form for user input:
<form>
HTML Input Types
Here are the different input types you can use in HTML:
<input type="text"> defines a single-line text input field:
Here is the output:
Input Type Submit
<input type="submit"> defines a button for submitting form data to a form-handler.
Here is the output:
Input Type Reset
<input type="reset"> defines a reset button that will reset all form values to their default values:
Here is the output:
Input Type Radio
<input type="radio"> defines a radio button.
Here is the output:
Input Type Checkbox
<input type="checkbox"> defines a checkbox.
Here is the output:
Input Type Button
<input type="button"> defines a button.
Here is the output:
Example
<form>
.
form elements
.
</form>
- <input type="button">
- <input type="checkbox">
- <input type="color">
- <input type="date">
- <input type="datetime-local">
- <input type="email">
- <input type="file">
- <input type="hidden">
- <input type="image">
- <input type="month">
- <input type="number">
- <input type="password">
- <input type="radio">
- <input type="range">
- <input type="reset">
- <input type="search">
- <input type="submit">
- <input type="tel">
- <input type="text">
- <input type="time">
- <input type="url">
- <input type="week">
Example
<form>
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname">
</form>
Example
<form action="/action_page.php">
<label for="fname">First name:</label><br>
<input type="text" id="fname" name="fname" value="John"><br>
<label for="lname">Last name:</label><br>
<input type="text" id="lname" name="lname" value="Doe"><br><br>
<input type="submit" value="Submit">
</form>
Example
<form action="/action_page.php">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname" value="John">
<label for="lname">Last name:</label>
<input type="text" id="lname" name="lname" value="Doe">
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
Example
<p>Choose your favorite Web language:</p>
<form>
<input type="radio" id="html" name="fav_language" value="HTML">
<label for="html">HTML</label>
<input type="radio" id="css" name="fav_language" value="CSS">
<label for="css">CSS</label>
<input type="radio" id="javascript" name="fav_language" value="JavaScript">
<label for="javascript">JavaScript</label>
</form>
Choose your favorite Web language: