Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Basic Form Controls – Textual Inputs | HTML Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. HTML Course

Lesson 5 of 55

·HTML

Basic Form Controls – Textual Inputs

10 min

Course progress9%

What you'll learn

Keep these ideas in mind as you work through the lesson.

5 points
  • Common textual input types (`text`, `email`, `url`, `tel`, `password`)
  • Built‑in validation attributes (`required`, `pattern`, `minlength`, `maxlength`)
  • Label association with `for`/`id` and its accessibility impact
  • Mobile keyboard optimization based on `type`
  • Best practices for placeholder usage

Text‑based input types

<label for='name'>Name:</label>
<input type='text' id='name' name='name' required minlength='2' autocomplete='name' placeholder='John Doe' />

<label for='email'>Email:</label>
<input type='email' id='email' name='email' required autocomplete='email' />

Input types

  • type='text' – Generic text.
  • type='email' – Validates email format; brings up an email‑optimized keyboard on mobile.
  • type='url', type='tel', type='search' – Specialized keyboards and validation.
  • type='password' – Hides characters; browsers may offer password‑manager integration.

Validation attributes

  • required – Field must be filled before submission.
  • pattern – Custom regular expression.
  • minlength, maxlength – Character count limits.
  • autocomplete – Hints for browsers to pre‑fill fields.
  • placeholder – Short hint visible inside the field; never replace a real <label>.

Label association

  • Always pair <label> with the control using for/id. This expands the clickable target and improves screen‑reader navigation.

Quick checklist for text inputs

  1. <label> correctly linked via for/id? ✅
  2. type matches expected data (email, url, tel, etc.)? ✅
  3. required added where needed? ✅
  4. autocomplete attribute present and appropriate? ✅
  5. placeholder used only as a hint, not a replacement for <label>? ✅

Tip: Match the type to the expected data (e.g., email for email addresses) to get native validation and the appropriate virtual keyboard on smartphones.

Make it stickPractice what you've learned1 quiz · 2 practical tests · Optional activities from HTML CourseBrowse activities
Previous lessonForms OverviewContinue to lesson 6Advanced Form Controls – Range, Color, FileBack to HTML Course curriculum