HTML <input> tag

Usage

Defines an input field to allow the user to enter information into a form.

Example

Code:

<form action="process.php" method="get">
Username:
<input type="text" name="username" />
<br />
Password:
<input type="password" name="password" />
<br />
<input type="submit" value="Login" />
</form>

Output:

Username:
Password:

Required Attributes

  • none

Optional Attributes

  • accept - use with type="file", specifies the file types to accept
  • alt - alternate text for the image when using type="image"
  • checked - specifies that the input should be checked by default, for use with checkboxes and radio buttons
  • disabled - the input field will be disabled when the page first loads
  • maxlength - when using a text input, this will limit the number of characters that the user can input
  • name - a unique name for the input field
  • readonly - the value of the input cannot be modified
  • size - sets the size of the input element
  • src - for image input types, specifies the URL of the image
  • type - button, checkbox, file, hidden, image, password, radio, reset, submit, text - specifies the type of input to use
  • value - defines a default value of the element (text, password, hidden), or the value to be passed to the processing page (radio buttons and checkboxes), or the text on the button (submit and reset)

Core Attributes