HTML <input> Tag
<input>tag is used within a form to declare an input element - a control that allows the user to input data.
- Example Code:
<form action="" method="post"> First name: <input type="text" name="first_name"> Last name: <input type="text" name="last_name"> <input type="submit" value="Submit"> </form>
Attribute Definition type Specifies the type of control.
name Assigns a name to the input control. value Specifies the value of an input element size Specifies the width of an input field maxlength Specifies the maximum length (in characters) of an input field (for type="text" or type="password") checked If type="radio" or type="checkbox" it will already be selected when the page loads. src If type="image", this attribute specifies the location of the image. align For alignment (left, center, right, justify). alt Alternate text. This specifies text to be used in case the browser/user agent can't render the input control. accept Specifies a comma-separated list of content types that the server accepts. readonly Sets the input control to read-only - it won't allow the user to change the value. The control however, can receive focus and are included when tabbing through the form controls. disabled Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing.
- Global Attributes:
<input>tag also supports the Global Attributes in HTML5
- Event Attributes:
<input>tag also supports the Event Attributes in HTML5