Coding/Learn/html/inputs
HTML Beginner Course
01.Introduction to HTML
02.Anatomy of an HTML Element
03.The Sacred HTML5 Skeleton
04.Headings (h1 to h6)
05.Paragraphs, Line Breaks & Dividers
06.Text Formatting & Emphasis
07.Hyperlinks & Navigation (<a>)
08.Images & The Sacred Alt Text (<img>)
09.Ordered & Unordered Lists (<ul>, <ol>, <li>)
10.Block vs Inline Elements
11.Generic Containers (<div> & <span>)
12.Semantic HTML (<header>, <nav>, <main>, <footer>)
13.Tables (<table>, <tr>, <th>, <td>)
14.Native Audio & Video Elements
15.The Invisible Brain (<head> & Meta Tags)
16.Interactive Forms (<form>)
17.Input Types (<input>)
18.Accessible Labels & Submit Buttons
19.Textareas & Select Dropdowns (<textarea>, <select>)
20.Capstone: Building Your First Web Profile Page
Course Certificate0%

Complete all lessons to earn

LearnInput Types (<input>)
17 / 20 0%
Lesson 17 of 20
5 mins read

Input Types (<input>)

PreviousNext Lesson
In Plain English

The versatile <input> tag changes its entire appearance and behavior based on its type attribute. Set type="password" to hide characters with dots, type="email" for built-in email validation, or type="checkbox" for toggleable checks.

The Mental Model

"<input> is like a chameleon. Put it on text leaves and it turns into a single-line textbox. Put it on password rocks and it turns into masked dots. Put it on checkbox flowers and it turns into a tick box."

Deep Dive: How It Works

type="text": Standard single-line text input.

type="email": Validates that the input contains an "@" and domain; opens email keyboards on mobile.

type="password": Masks characters with secure bullets or asterisks.

type="number": Restricts input to numbers and adds increment arrows.

type="checkbox": Square boxes for multiple choice selections.

type="radio": Round buttons where selecting one unselects other radio buttons in the same name group.

type="date": Opens native calendar date pickers.

Syntax Blueprint

<input type="text" name="username" placeholder="Enter username">
<input type="password" name="pwd">
<input type="checkbox" name="agree">

Self-closing void input tag configured by type and name attributes.

PointCore Rules to Remember

Point star
The Name Attribute is Crucial: Without a name="..." attribute, form submissions will not include the input's value.
Point star
Placeholder Text: Use placeholder="..." to show helpful hints before the user types.
Point star
Required Validation: Add the boolean required attribute to stop forms submitting empty fields.

Common Beginner Traps & How to Fix Them

Mistake:Forgetting matching name on radio buttons

Why it happens: If radio buttons have different names, users can accidentally check all of them simultaneously.

How to fix: Give all radio buttons in a question group the EXACT same name="group_name".

Pro Tip: Use type="tel" for phone numbers so smartphones automatically pull up the 10-digit number pad keyboard!

Live Interactive Example

Hit Run Code to see it live
Common Input Types in Action
HTML5
1
2
3
4
5
Live Browser Preview
Click "Preview / Apply" to view the rendered output.
How it works: The browser natively validates email formatting and masks password characters.

Your Turn: Micro Challenge

No pressure! Edit the starter code below and test your solution with instant feedback.

Micro Exercise

Create an email and password input pair

  • PointWrite an <input> of type="email" with placeholder="Email"
  • PointBelow it, write an <input> of type="password" with placeholder="Password"
1
2
Browser Preview & Output
Click "Check HTML" to test your solution.

Finished reading and practicing?

Mark this lesson as completed to update your course progress.

PreviousNext Lesson
Overview100 SheetLearnCertificates