Loading
The <input> element is one of the most important form elements in HTML. It is used to collect different types of user input on a web page, like names, passwords, email addresses, dates, and more.
Depending on its type attribute, it can appear as a text box, radio button, checkbox, file uploader, and more making it versatile for all kinds of forms.


Example: Name Input

<form>
  Enter your name: <br>
  <input type="text" name="username">
</form>

Output:

Uploaded Image




Common HTML Input Types

Here is a list of useful input types in HTML:

Input TypeDescription
textA single-line text input
passwordHides text input (e.g. for passwords)
emailValidates input as an email address
numberNumeric input only
radioSelect one option from a group
checkboxSelect one or more options
fileUpload files
submitSubmit the form
resetReset the form
buttonGeneric button for custom actions
dateSelect a date 
datetime-localSelect date and time
colorChoose a color
telInput for phone numbers
urlValidates as a URL 
rangeSlider input ( range between values )



Example: Student Details Form

<h2>Student Registration Form</h2>
<form>
  <label for="name">Name:</label>
  <input type="text" id="name" placeholder="Enter name" required><br><br>

  <label for="email">Email:</label>
  <input type="email" id="email" placeholder="Enter email" required><br><br>

  <label for="password">Password:</label>
  <input type="password" id="password" placeholder="Enter password"><br><br>

  <label for="age">Age:</label>
  <input type="number" id="age" min="1"><br><br>

  <label for="dob">Date of Birth:</label>
  <input type="date" id="dob"><br><br>

  <label>Gender:</label><br>
  <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><br>

  <label>Hobbies:</label><br>
  <input type="checkbox" id="reading" value="Reading"><label for="reading">Reading</label><br>
  <input type="checkbox" id="sports" value="Sports"><label for="sports">Sports</label><br><br>

  <label for="file">Upload Photo:</label>
  <input type="file" id="file"><br><br>

  <input type="submit" value="Register">
</form>

Output:

Uploaded Image



Key Point

  • Always use meaningful labels with inputs.
  • Use type attributes to control the behavior of the <input> element.
  • Combine with <form> to send the data to a server.
  • Add required to make any field mandatory.