Input, Select, Textarea, and Button Attributes

Input, Select, Textarea, and Button Attributes

This chapter focuses on the most attribute-rich controls in HTML.

<input> Attributes

Important attributes:

  • type
  • name
  • id
  • value
  • placeholder
  • required
  • disabled
  • readonly
  • checked
  • min
  • max
  • step
  • minlength
  • maxlength
  • pattern
  • autocomplete
  • multiple
  • accept
  • list

Common type values:

  • text
  • email
  • password
  • number
  • date
  • range
  • checkbox
  • radio
  • file
  • search
  • url
  • tel
  • hidden
  • submit

<select> Attributes

  • name
  • id
  • required
  • multiple
  • size
  • disabled

<option> Attributes

  • value
  • label
  • selected
  • disabled

<textarea> Attributes

  • name
  • id
  • rows
  • cols
  • placeholder
  • required
  • readonly
  • maxlength

<button> Attributes

  • type
  • name
  • value
  • disabled

Possible type values:

  • submit
  • button
  • reset

Example of Several Controls

<form>
    <input type="email" name="email" placeholder="you@example.com" required>
    <select name="level">
        <option value="beginner">Beginner</option>
        <option value="intermediate">Intermediate</option>
    </select>
    <textarea name="message" rows="4" cols="30"></textarea>
    <button type="submit">Send</button>
</form>

Why These Attributes Matter

They control:

  • validation
  • defaults
  • accessibility
  • submission data
  • user experience