HTML

Last Updated: 10/5/2022

Input Attributes

  • autofocus
    • Specifies that an input field should automatically get focus when the page loads.
  • autocomplete
    • Specifies whether a form or an input field should have autocomplete on or off.
    • Specifies whether the browser should display options to fill in the field, based on earlier typed values.
  • placeholder:
    • Specifies a short hint that describes the expected value of an input field
    • Displayed in the input field before the user enters a value.
  • value:
    • Specifies an initial value for an input field
  • readonly:
    • Specifies that an input field is read-only.
    • The value of a read-only input field will be sent when submitting the form!
  • disabled
    • Specifies that an input field should be disabled.
    • The value of a disabled input field will not be sent when submitting the form!
  • size
    • Specifies the visible width, in characters, of an input field.
    • Default value for size is 20.
  • multiple:
    • Specifies that the user is allowed to select more than 1 file when used with file control.
  • checked:
    • Specifies that an <input> element should be pre-selected when the page loads (for checkbox or radio)
  • required:
    • Specifies that an input field must be filled out before submitting the form.
  • minlength:
    • Specifies the minimum number of characters required in an <input> element
  • maxlength:
    • Specifies the maximum number of characters allowed in an input field.
  • pattern
    • Specifies a regular expression that the input field's value is checked against, when the form is submitted
    • Works with the following input types: text, date, search, url, tel, email, and password.
  • step
    • Specifies the number intervals for an input field.
    • Works with the following input types: number, range, date, datetime-local, month, time and week.
  • min and max
    • min and max attributes specify the minimum and maximum values for an input field.
    • work with the following input types: number, range, date, datetime-local, month, time and week.
    • Use the max and min attributes together to create a range of legal values.
  • pattern:
    • specifies a regular expression that the input field's value is checked against, when the form is submitted.
    • works with the following input types: text, date, search, url, tel, email, and password.
  • accept
    • Specifies what file types the user can pick from the file input.
    • To specify more than one value, separate the values with a comma
    • eg <input accept="audio/*,video/*,image/*" />

Input Form Attributes

Overrides the attribute of the <form> element. Works with the following input types: submit and image.

  • formaction
  • formenctype
  • formmethod
  • formnovalidate
  • formtarget