Skip to content
Learn Netverks

Lesson

Step 43/58 74% through track

input-attributes

Input attributes

Last reviewed Jun 1, 2026 Content v20260601
Track mode
iframe_html
Means
HTML preview sandbox
Reading
~2 min
Level
advanced

This lesson

This lesson teaches Input attributes—the ideas, syntax, and habits you need before moving on in HTML.

Without a solid grasp of Input attributes, you will repeat mistakes in HTML exercises and on real pages or scripts.

You will apply Input attributes in contexts like: Websites, hybrid apps, email templates, design systems, and CMS-driven content.

Read the lesson, edit HTML/CSS in the playground, press Run to preview, then answer the lesson MCQs. Also use the HTML reference desk when you need tag or attribute lookup.

When intermediate lessons feel comfortable and you are ready for production-style trade-offs.

Dozens of attributes tune inputs: defaults, lengths, formatting, masking, linkage to errors, hints for automation. Below is the high-signal set you use daily—each with a miniature example.

Attribute matrix (what affects what)

Value & size
value, defaultValue (DOM), size, maxlength/minlength
Validity
required, pattern, min/max/step
Availability
disabled (skipped in submit), readonly (submitted)
Hints
placeholder, autocomplete, inputmode, list (datalist hook)
Multimedia-ish
multiple (email/file), accept/capture (files)

Example — lengths, placeholders, autocomplete

<input type="text" name="coupon" maxlength="8" placeholder="SHIP2026" autocomplete="off">

Rendered

Example — pattern + visible label hint

<label for="zip">US ZIP (+4 optional)</label>
<input id="zip" inputmode="numeric" pattern="\d{5}(-\d{4})?" title="Five digits optionally dash four" placeholder="97205-1234">

Rendered (try mismatched chars)

Example — readonly vs disabled

<input readonly value="submitted">
<input disabled value="omitted">

Value & defaults

  • value: initial or submitted content.
  • defaultValue (DOM property) differs from live value after edits.

Constraints

  • required, minlength/maxlength, pattern.
  • min/max/step for numeric/temporal types.
  • multiple on email/file/select (when applicable).

State

  • disabled: excluded from submission, unfocusable.
  • readonly: still submits values but blocks edits.

Hints

placeholder is not a substitute for labels—it disappears when users type.

ARIA for errors

Toggle aria-invalid and reference descriptive elements when validation fails.

Easily overlooked input states

  • Indeterminate checkboxes: tri-state UX via JS properties—expose meaning to SR with aria-checked="mixed" patterns.
  • Controlled vs uncontrolled? in SPAs resetting forms after submit must restore defaults intentionally—otherwise stale values linger in memory DOM.

Assistive announcements

Use live regions sparingly when async validation completes—duplicate announcements annoy; silent failures exclude.

Important interview questions and answers

  1. Q: Why are native form controls preferred over custom div-based widgets?
    A: They provide built-in semantics, keyboard support, validation hooks, and accessibility behavior.
  2. Q: What does `name` do on form fields?
    A: It determines the key sent in form submission payloads; without `name`, values are typically not submitted.
  3. Q: When should you use `type="button"` instead of default buttons in forms?
    A: Use `type="button"` for non-submit actions to avoid accidental form submission.

Pitfall: Placeholder is not a label—always associate a visible label.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Community stories on this track

Learner essays linked to HTML — not official lesson content.

Browse all stories

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • What confused you about this lesson?
  • How would you explain this to a teammate in 30 seconds?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump