HTML Input Attributes

Input attributes define how input fields behave.


Common Input Attributes

<input 
  type="text"
  name="username"
  id="user"
  value="John"
  placeholder="Enter name"
  required
  readonly
  maxlength="20">

Attributes Explained

  • name → field identifier
  • id → unique element ID
  • value → default value
  • placeholder → hint text
  • required → mandatory field
  • readonly → non-editable
  • maxlength → character limit

Important Notes

  • Attributes improve usability
  • Validation can be client-side
  • Use meaningful names