HTML Inputs

Beginner
14 min read
Updated: Nov 2026
6 examples
input types

Definition and Usage

HTML inputs are the controls people use to enter data on a webpage—names, emails, passwords, numbers, dates, files, and choices. One element, <input>, becomes many widgets through its type attribute.

How do inputs fit an HTML page?

Place inputs inside a <form> when values should submit together. Pair every visible control with a <label>. Give each field a name so the browser can send the value.

Why does type matter?

type changes the UI and validation: email checks format, password hides characters, number offers a spinner, date opens a calendar, file opens a picker. The default type is text.

Inputs vs the input tag page

This tutorial is a tour of common types for HTML authors building forms. The input tag reference covers attributes and type specifics in depth.

Label every field.

Use <label for="id"> matching the input’s id. Do not rely on placeholder alone.

name is required for submit.

Without name, many browsers omit the field when the form is submitted.

Prefer the right type.

Matching types improve mobile keyboards and built-in validation—use email, tel, url, and number when they fit.

HTML Syntax

Labeled fields inside a form:

HTML
<form action="/register" method="post">
  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>

  <label for="pwd">Password</label>
  <input type="password" id="pwd" name="password" required>

  <input type="checkbox" id="news" name="subscribe" value="yes">
  <label for="news">Subscribe</label>

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

Core HTML Concepts

Common type values you will use most often:

typePurpose
textSingle-line text (default)
email / password / tel / url / searchSpecialized text fields
number / rangeNumeric value or slider
checkboxOn/off (or many) choices
radioOne choice in a named group
date / time / datetime-localCalendar / time pickers
fileUpload files
colorColor picker
hiddenValue sent, not shown
submit / button / reset / imageForm buttons

Shared attributes

AttributeRole
nameKey sent with the form data
idHook for label for="…"
valueCurrent or submitted value
placeholderHint text (not a label)
requiredMust be filled before submit
disabled / readonlyBlock editing (disabled is not submitted)
min / max / stepLimits for number/date/range
acceptFile type hint for file

Radio vs checkbox

radiocheckbox
SelectionOne in the groupAny combination
GroupingSame nameUsually unique names
Typical useGender, shipping methodAgree to terms, add-ons

How to Add Inputs to an HTML Page

A practical workflow:

  1. Wrap fields in a <form> with action and method when submitting.
  2. Choose the type that matches the data (email, number, date…).
  3. Add id + <label for> for every visible control.
  4. Set name (and value for radios/checkboxes).
  5. Use required, min/max, or pattern for basic validation.
  6. Finish with type="submit" (or a <button type="submit">).
GoalPattern
Text field<input type="text" name="username">
One of manyRadios with the same name
Optional add-on<input type="checkbox" name="…">
Uploadtype="file" (+ accept)
Send the form<input type="submit" value="Send">

Live Preview

Switch input types and see how the control changes.

Same label and name; only type changes.

Preview

HTML Examples

Six patterns: text, email/password, number, radio/checkbox, date/file, and a full form.

Example 1 — Text Input

HTML
<label for="username">Username</label>
<input type="text" id="username" name="username" placeholder="Enter your username">
Try It Yourself

How It Works

  1. type="text" is the default single-line field.
  2. label for matches the input id.
  3. name identifies the value on submit.
  4. placeholder is a hint, not a replacement for the label.

Example 2 — Email and Password

HTML
<input type="email" name="email" placeholder="[email protected]" required>
<input type="password" name="password" placeholder="Enter password" required>
Try It Yourself

How It Works

  1. email validates basic format on submit.
  2. password masks characters as you type.
  3. required blocks empty submits.
  4. Mobile browsers often show a matching keyboard for email.

Example 3 — Number Input

HTML
<input type="number" name="age" min="1" max="100" value="25">
Try It Yourself

How It Works

  1. number expects a numeric value.
  2. min / max set the allowed range.
  3. value provides a starting number.
  4. Spinners appear in many desktop browsers.

Example 4 — Radio and Checkbox

HTML
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="checkbox" id="subscribe" name="subscribe" value="newsletter">
<label for="subscribe">Subscribe</label>
Try It Yourself

How It Works

  1. Radios with the same name form one group.
  2. value is what gets submitted for the chosen option.
  3. Checkboxes toggle independently.
  4. Labels enlarge the click/tap target.

Example 5 — Date and File

HTML
<input type="date" name="birthdate">
<input type="file" name="resume" accept=".pdf,.doc,.docx">
Try It Yourself

How It Works

  1. date opens a native date UI when supported.
  2. file opens the system file dialog.
  3. accept hints allowed extensions (not a security filter alone).
  4. Always validate uploads on the server too.

Example 6 — Complete Inputs Form

HTML
<form>
  <label for="username">Username</label>
  <input type="text" id="username" name="username" required>

  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>

  <label for="age">Age</label>
  <input type="number" id="age" name="age" min="0" max="120">

  <label for="birthdate">Birthdate</label>
  <input type="date" id="birthdate" name="birthdate">

  <p>Gender:
    <input type="radio" name="gender" value="male"> Male
    <input type="radio" name="gender" value="female"> Female
  </p>
  <p><input type="checkbox" name="subscribe"> Subscribe</p>
  <input type="file" name="resume">
  <input type="submit" value="Register">
</form>
Try It Yourself

How It Works

  1. One form mixes several input types.
  2. Labels stay paired with each field.
  3. submit triggers browser validation for required / email.
  4. Try It opens the full editable registration page.

Edge Cases & Pitfalls

Most input bugs are missing labels, missing names, or the wrong type.

a11y

Placeholder instead of a label

Placeholders vanish while typing and are weaker for screen readers. Keep a real label.

submit

No name on the field

Unnamed controls often never reach the server.

radio

Radios with different names

They will not act as one group. Share the same name.

type

Using text for everything

You lose mobile keyboards and built-in checks. Prefer email, tel, number, date when appropriate.

file

Trusting accept alone

accept is a hint. Always validate files server-side.

reset

type="reset" by default

Reset buttons often frustrate users. Prefer clear, intentional UI instead.

Browser Support

Core input types (text, email, password, number, checkbox, radio, file, submit) are Baseline. Some newer types (week, month) vary—always provide a usable fallback experience.

✓ Baseline · Widely available

HTML form inputs

Interactive form controls via input work across modern browsers; type support can vary for niche pickers.

95% Common types
Google Chrome All versions · Desktop & Mobile
Full support
Mozilla Firefox All versions · Desktop & Mobile
Full support
Apple Safari All versions · macOS & iOS
Full support
Microsoft Edge All versions · Chromium & Legacy
Full support
Internet Explorer IE 6+ · Legacy environments
Full support
Opera All modern versions
Full support
HTML inputs Core types

Bottom line: Pick the right type, label every field, and put name on anything you want submitted.

Key Takeaways

  • type decides the control—text, email, number, radio, file, and more.
  • label + name make fields usable and submittable.
  • Radios share name; checkboxes stand alone.
  • Deep attributes live on /html/tags/input; form wrapping on /html/form.

One line: Choose the right type, label the control, give it a name, and place it in a form when you need to submit.

Frequently Asked Questions

Input elements are form controls that collect data from users—text, emails, passwords, numbers, dates, files, choices, and buttons. The type attribute decides which control the browser shows.
This tutorial is a practical guide to common input types on HTML pages (when to use which type, labels, grouping). The /html/tags/input page is the element reference with attributes and type details.
Inputs can appear alone for demos, but real pages usually put them inside a form so values submit together with name attributes. See the HTML Forms tutorial.
email adds format checks on submit and often shows a better keyboard on phones. Prefer the matching type whenever you can.
Radio buttons that share a name let the user pick one option. Checkboxes can be on or off independently (or select many).
No. Always use a visible label (or aria-label). Placeholder is a short hint and disappears when the user types.

Practice in the editor

Open a Try It demo and build a full registration form with many input types.

Open Try It editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful