# Input Elements

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1722498899779/c8787241-0647-4a6e-b105-fefe40efc659.png align="center")

The HTML **&lt;input&gt;** tag is used within a form where the user can enter data.

The way how to the HTML **&lt;input&gt;** tag displays depend on the type of attribute that is paired with:

Syntax:

&lt;input type=""&gt;

`The different input types are as follows:`

1. Input Type Button **&lt;input type=”button”&gt;**
    
2. Input Type Checkbox **&lt;input type=”checkbox”&gt;**
    
3. Input Type Color **&lt;input type=”color”&gt;**
    
4. Input Type Date **&lt;input type=”date”&gt;**
    
5. Input Type Datetime-local **&lt;input type=”datetime-local”&gt;**
    
6. Input Type Email **&lt;input type=”email”&gt;**
    
7. Input Type File **&lt;input type=”file”&gt;**
    
8. Input Type Hidden **&lt;input type=”hidden”&gt;**
    
9. Input Type Image **&lt;input type=”image”&gt;**
    
10. Input Type Month **&lt;input type=”month”&gt;**
    
11. Input Type Number **&lt;input type=”number”&gt;**
    
12. Input Type Password **&lt;input type=”password”&gt;**
    
13. Input Type Radio **&lt;input type=”radio”&gt;**
    
14. Input Type Range **&lt;input type=”range”&gt;**
    
15. Input Type Reset **&lt;input type=”reset”&gt;**
    
16. Input Type Search **&lt;input type=”search”&gt;**
    
17. Input Type Submit **&lt;input type=”submit”&gt;**
    
18. Input Type Tel **&lt;input type=”tel”&gt;**
    
19. Input Type Text **&lt;input type=”text”&gt;**
    
20. Input Type Time **&lt;input type=”time”&gt;**
    
21. Input Type URL **&lt;input type=”url”&gt;**
    
22. Input Type Week **&lt;input type=”week”&gt;**
    

## Input Elements :

### Input Type Button

The HTML **&lt;input type=”button”&gt;** is used to provide a button to the input field. It always comes with the *value* attribute. We use *the value* attribute to give the name to the button.

```xml
<!DOCTYPE html>
<html>
<body>

<input type="button" value="Click Me!">

</body>
</html>
```

### Input Type Checkbox

The HTML **&lt;input type=”checkbox”&gt;** is used to provide a checkbox to the input field.

```xml
<!DOCTYPE html>
<html>
<body>

<p>What is your favourite colour?</p>

<form action="">
  <input type="checkbox" id="red" name="red" value="red">
  <label for="red">Red</label><br>
  <input type="checkbox" id="blue" name="blue" value="Blue">
  <label for="blue">Blue</label><br>
  <input type="checkbox" id="green" name="green" value="green">
  <label for="green">Green</label><br><br>
</form> 

</body>
</html>
```

### Input Type Color

The HTML **&lt;input type=”color”&gt;** is used for input fields that contain color.

```xml
<!DOCTYPE html>
<html>
<body>

<h4>Show a Color Picker:</h4>

<form action="">
  <label for="color">Select a color:</label>
  <input type="color" id="color" name="color" value="#00bfff">
</form>

</body>
</html>
```

### Input Type Date

The HTML **&lt;input type=”date”&gt;** is used for input fields that contain a date.

```xml
<form action="">
  <label for="work-meeting">Work meeting:</label>
  <input type="date" id="work-meeting" name="work-meeting">
  
</form>
```

### Input Type Email

The HTML **&lt;input type=”email”&gt;** is used for input fields that contain an email address.

```xml
<form action="">
  <label for="email">Type an email:</label>
  <input type="email" id="email" name="email">
</form>
```

### Input Type Image

The HTML **&lt;input type=”image”&gt;** specifies an image as a submit button.

```xml
<form action="">
  <label for="fname">First name: </label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Last name: </label>
  <input type="text" id="lname" name="lname"><br>
  <input type="image" src="https://lenadesign.org/wp-content/uploads/2021/06/submit-button.png" alt="Submit" width="100" height="100">
</form>
```

### Input Type Password

The HTML **&lt;input type=”password”&gt;** specifies a password field.

```xml
<form action="">
  <label for="username">Username:</label><br>
  <input type="text" id="username" name="username"><br>
  <label for="pwd">Password:</label><br>
  <input type="password" id="pwd" name="pwd"><br>
</form>
```

### Input Type Search

The HTML **&lt;input type=”search”&gt;** is used for search fields.

```xml
<form action="">
  <label for="gsearch">Search:</label>
  <input type="search" id="search" name="search">
</form>
```

### Input Type Number

The HTML **&lt;input type=”number”&gt;** specifies a numeric input field.

```xml
<form action="">
  <label for="quantity">Amount (select between 1 and 10):</label>
  <input type="number" id="amount" name="amount" min="1" max="10">
</form>
```

### Input Type Radio

The HTML **&lt;input type=”radio”&gt;** is used to provide a radio button to the input field.

```xml
<!DOCTYPE html>
<html>
<body>

<p>What is your favourite colour?</p>

<form action="">
  <input type="radio" id="blue" name="colour" value="blue">
  <label for="blue">Blue</label><br>
  <input type="radio" id="yellow" name="colour" value="yellow">
  <label for="yellow">Yellow</label><br>
  <input type="radio" id="other" name="colour" value="other">
  <label for="other">Other</label><br><br>
</form> 

</body>
</html>
```

### Input Type Submit

The HTML **&lt;input type=”submit”&gt;** specifies a button for submitting.

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

### Input Type Tel

The HTML **&lt;input type=”tel”&gt;** is used for input fields that contain a telephone number.

```xml
<form action="">
  <label for="phone">Type a telephone number:</label><br>
  <input type="tel" id="phone" name="phone" placeholder="123-45-678" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" required><br>
  <small>Format: 123-45-678</small><br>
</form>
```

### Input Type Text

The HTML **&lt;input type=”text”&gt;** specifies a line text input field.

```xml
<form action="">
  <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"><br><br>
</form>
```

### Input Type Time

The HTML **&lt;input type=”time”&gt;** allows the user to select a time (no the time zone).

```xml
<form action="">
  <label for="select-time">Select a time:</label>
  <input type="time" id="select-time" name="select-time">
</form>
```

### Input Type URL

The HTML **&lt;input type=”url”&gt;** is used for input fields that contain a URL address

```xml
<form action="">
  <label for="homepage">Add your web page :</label>
  <input type="url" id="webPage" name="webPage">
</form>
```

### Input Type Week

The HTML **&lt;input type=”week”&gt;** allows the user to select a week and year.

```xml
<form action="">
  <label for="week">Select a week:</label>
  <input type="week" id="week" name="week">  
</form>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1722501444680/33739a39-af78-4721-9e7b-11e3f7f54369.jpeg align="center")
