HTML Tutorial: HTML Forms
Tags: html, webdev, 100daysofcode, forms
Published: 2021-06-10 18:45:56

---
title: HTML Tutorial:  HTML Forms
published: true
date: 2021-01-10 01:16:04 UTC
tags:  html5, html, webdevelopment, 100daysofcode, forms
canonical_url: https://www.devwares.com/blog//html-forms
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7b64am2e4mnw8ox1zn49.png
series: Devwares Web development Free Course
---

A HTML form is used to collect user input. Which is usually sent to a server for processing.

![AD-BANNER](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/41meil9ho9yx2ulb535m.png)

## Form Element:

The `<form>` element is used to create an HTML form to user input.

## Input Element:

The HTML `<input>` element is the most used form element

### Text field:

The `<input type ="text">` defines a single-line input field for text input.

```html
<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>

```

### This will look like:
<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>
## The Label Element:

The `<label>` tag serves to label for many form elements. It is useful for screen-reader users, because this will help them read out loud the label when the user focuses on the input element. It is also used by people with difficulty clicking on small region.

## Radio buttons:

The `<input type = "radio">` defines the radio button.

```html
<form>
  <input type ="radio" id = "male" name="gender" value="male">
  <label for ="male">Male</label>
  <br>
  <input type ="radio" id = "female" name="gender" value="female">
  <label for ="female">Female</label>
  <input type ="radio" id = "Other" name="gender" value="other">
  <label for ="other">Other</label>
</form>

```

### This will look like:
<form>
<input type="radio" id="male" name="gender" value="male"><label for="male">Male</label><br><input type="radio" id="female" name="gender" value="female"><label for="female">Female</label><br><input type="radio" id="Other" name="gender" value="other"><label for="other">Other</label>
</form>
## Checkboxes

The `<input type= "checkbox">` shows a checkbox. This gives users zero or more options to a limited amount of choice.

```html
<form>
    <input type = "checkbox" id = "vehicle1" name ="vehicle1" value= "Bike">
      <label for = "vehicle1"> I have a bike</label>
        <br>
    <input type = "checkbox" id = "vehicle2" name ="vehicle2" value= "Car">
      <label for = "vehicle2"> I have a car</label>
</form>

```

### This will look like:
<form>
<input type="checkbox" id="vehicle1" name="vehicle1" value="Bike"><label for="vehicle1"> I have a bike</label><br><input type="checkbox" id="vehicle2" name="vehicle2" value="Car"><label for="vehicle2"> I have a car</label>
</form>
## The Submit button

The `<input type="submit">` shows a button for submitting the form data to a form handler. The form handler is a file on a server with a script for processing input data.

```html
<form action = "action_page.php">
  <label for ="fname">First name: </label><br>
  <input type ="text" id="fname" name="fname" value = "Emma"><br>
  <label for ="lname">Last name: </label><br>
  <input type ="text" id="lname" name="lname" value = "Smith"><br><br>
  <input type = "submit" value = "Submit">
</form>

```

### This will look like:
<form action="action_page.php">
<label for="fname">First name: </label><br><input type="text" id="fname" name="fname" value="Emma"><br><label for="lname">Last name: </label><br><input type="text" id="lname" name="lname" value="Smith"><br><br><input type="submit" value="Submit">
</form>
## The name attribute for input tag

The name attribute is very important because if its omitted the value in the input field will not be sent at all.

```html
<input name="FirstName" type="text" />

```


###Create Stunning Websites and Web Apps

Building different custom components in react for your web apps or websites can get very stressful. That's why we decided to build contrast. We have put together a UI kit with over 10000+ components, 5 admin dashboards and 23 additional different pages template for building almost any type of web app or webpage into a single product called Contrast Pro. [Try contrast pro!](https://www.devwares.com/product/contrast-pro)

![Contrast Design Boostrap](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ulsutxnzjpbpaauhvbew.png)

Contrast React Bootstrap PRO is a Multipurpose pro template, UI kit to build your next landing, admin, SAAS, prelaunch, etc. project with a clean, well documented, well crafted template and UI components. [Learn more about Contrast Pro](https://www.devwares.com/product/contrast-pro)

## Resources 

- [Contrast Design Bootstrap](https://www.devwares.com/docs/contrast/javascript/index/)
- [Accordion](https://www.devwares.com/docs/contrast/javascript/components/accordion/)
- [Alert](https://www.devwares.com/docs/contrast/javascript/components/alert/)
- [Animation](https://www.devwares.com/docs/contrast/javascript/components/animations/)
- [Autocomplete](https://www.devwares.com/docs/contrast/javascript/components/autocomplete/)
- [Badges](https://www.devwares.com/docs/contrast/javascript/components/badge/)
- [Box](https://www.devwares.com/docs/contrast/javascript/components/box/)
- [Breadcrumb](https://www.devwares.com/docs/contrast/javascript/components/breadcrumb/)
- [ButtonGroup](https://www.devwares.com/docs/contrast/javascript/components/buttonGroup/)
- [Button](https://www.devwares.com/docs/contrast/javascript/components/buttons/)
- [ButtonToolbar](https://www.devwares.com/docs/contrast/javascript/components/buttonToolbar/)
- [Card](https://www.devwares.com/docs/contrast/javascript/components/card/)
- [Carousel](https://www.devwares.com/docs/contrast/javascript/components/carousel/)
- [Checkbox](https://www.devwares.com/docs/contrast/javascript/components/checkbox/)
- [Collapse](https://www.devwares.com/docs/contrast/javascript/components/collapse/)
- [DataTable](https://www.devwares.com/docs/contrast/javascript/components/datatables/)
- [DatePicker](https://www.devwares.com/docs/contrast/javascript/components/datepicker/)
- [DropDown](https://www.devwares.com/docs/contrast/javascript/components/dropdown/)
- [Footer](https://www.devwares.com/docs/contrast/javascript/components/footer/)
- [Forms](https://www.devwares.com/docs/contrast/javascript/components/forms/)
- [Icon](https://www.devwares.com/docs/contrast/javascript/components/icon/)
- [Iframe](https://www.devwares.com/docs/contrast/javascript/components/iframe/)
- [Input](https://www.devwares.com/docs/contrast/javascript/components/input/)
- [InputGroup](https://www.devwares.com/docs/contrast/javascript/components/inputgroup/)
- [ListGroup](https://www.devwares.com/docs/contrast/javascript/components/listgroup/)
- [Mask](https://www.devwares.com/docs/contrast/javascript/components/mask/)
- [Modal](https://www.devwares.com/docs/contrast/javascript/components/modal/)
- [Multiselect](https://www.devwares.com/docs/contrast/javascript/components/multiselect/)
- [Notification](https://www.devwares.com/docs/contrast/javascript/components/notification/)
- [Pane](https://www.devwares.com/docs/contrast/javascript/components/pane/)
- [Panel](https://www.devwares.com/docs/contrast/javascript/components/panels/)
- [Pop Over](https://www.devwares.com/docs/contrast/javascript/components/popover/)
- [Progress](https://www.devwares.com/docs/contrast/javascript/components/progress/)
- [Radio](https://www.devwares.com/docs/contrast/javascript/components/radio/)
- [Rating](https://www.devwares.com/docs/contrast/javascript/components/rating/)
- [Select](https://www.devwares.com/docs/contrast/javascript/components/select/)
- [Select 2](https://www.devwares.com/docs/contrast/javascript/components/select2/)
- [Slider](https://www.devwares.com/docs/contrast/javascript/components/slider/)
- [Spinner](https://www.devwares.com/docs/contrast/javascript/components/spinner/)
- [Stepper](https://www.devwares.com/docs/contrast/javascript/components/stepper/)
- [Switch](https://www.devwares.com/docs/contrast/javascript/components/switch/)
- [Table](https://www.devwares.com/docs/contrast/javascript/components/table/)
- [Forms](https://www.devwares.com/docs/contrast/javascript/forms/)
- [Navbar](https://www.devwares.com/docs/contrast/javascript/navigation/navbar/)
- [Pagination](https://www.devwares.com/docs/contrast/javascript/navigation/pagination/)
- [Tab](https://www.devwares.com/docs/contrast/javascript/navigation/tabs/)
- [Sidebar](https://www.devwares.com/docs/contrast/javascript/navigation/sidebar/)
- [Time Picker](https://www.devwares.com/docs/contrast/javascript/sections/timepicker/)
- [Data Table](https://www.devwares.com/docs/contrast/javascript/table/datatables/)
- [Fixed Data Table](https://www.devwares.com/docs/contrast/javascript/table/fixed_datatables/)
- [Table](https://www.devwares.com/docs/contrast/javascript/table/table/)
- [Widgets](https://www.devwares.com/docs/contrast/javascript/widgets/)