HTML Input Attributes

What are Input Attributes?

Input attributes define behavior and restrictions of input fields.

Example

<form>

  <input type="text" placeholder="Enter name" required><br><br>

  <input type="text" value="Fixed value" readonly><br><br>

  <input type="text" maxlength="10" placeholder="Max 10 chars"><br><br>

  <input type="email" placeholder="Email" disabled><br><br>

  <input type="submit" value="Submit">

</form>
Try it Yourself

required

Must fill field

placeholder

Hint text

readonly

Cannot edit value

Live Preview

Summary

  • required = must fill field
  • placeholder = hint text
  • readonly = non editable
  • maxlength = limit characters