Course contentsShow
← Web Development
Lesson 93 of 2,9822. HTML FundamentalsFree lesson

Password and Search Inputs

Implementing password fields with masking and search inputs with clear buttons and special behavior.

Password and Search Inputs

You'll learn how to create secure password fields that hide user input and search boxes with built-in browser features.

What Makes These Inputs Special?

You've already learned about basic text inputs like email and tel. Now we'll cover two specialized input types that behave differently: password and search.

The Password Input

When a user types sensitive information like a password, you don't want it visible on screen. The password input automatically masks each character (usually showing dots or asterisks):

<form>
  <label for="user-password">Password:</label>
  <input type="password" id="user-password" name="password">
</form>

Think of it like writing a secret note through carbon paper — the input exists, but nobody looking over your shoulder can read it.

Behind the scenes, the browser:

  • Hides characters as you type
  • Prevents copy/paste in some browsers
  • May offer to save credentials
  • Still sends the actual text when the form submits (use HTTPS!)

The Search Input

The search input looks similar to text input but adds helpful browser features:

<form>
  <label for="site-search">Search:</label>
  <input type="search" id="site-search" name="q">
</form>

Special behaviors include:

  • An automatic clear button (×) appears when you type
  • Rounded corners on some browsers
  • May remember previous searches
  • Enter key can trigger search submission

It's like having a built-in eraser — users can quickly clear their search and try again.

When to Use Each

Use type="password" for any sensitive data entry: passwords, PINs, security codes.

Use type="search" for search boxes, filters, or any "find something" interface.

Key Takeaway: Password inputs protect sensitive data through character masking, while search inputs provide enhanced usability with clear buttons and search-specific browser features.