<input> tag in HTML

The <input> tag is used to defines an input field where the user can enter input data OR allows the user to input data. The <input> elements are used to declare input controls within a <form> element.

Important Description

  • The <input> tag has no end tag in HTML, and does not need a closing tag.
  • But <input> tag must be properly closed in XHTML, it's look like <input />.
  • The <input> element is an empty tag.

Example of <input> tag

Result Look Like

First name:

Last name:

<input> Tag Browser Support

Element Chrome Edge Firefox Safari Opera
<input> Yes Yes Yes Yes Yes

Global Attributes

Event Attributes

Attributes

The 'align' attribute is not supported in HTML5:

Attribute Values Description
accept content types Specifies a filter for what file types the user can pick from the file input dialog box
alt text Specifies an alternate text for images
autocomplete on
off
Specifies whether an <input> element should have autocomplete enabled
autofocus autofocus Defines that <input> element should automatically get focus when the page loads
checked checked Defines that type = "radio" or type = "checkbox" it will already be selected when the page loads.
disabled disabled Disables the input control
form form_id Defines one or more forms the <input> element belongs to
formaction URL Defines the URL of the file that will process the input control when the form is submitted
formaction URL Defines the URL of the file that will process the input control when the form is submitted
formenctype application/x-www-form-urlencoded
multipart/form-data
text/plain
Defines how the form-data should be encoded when submitting it to the server
formmethod get
post
Defines the HTTP method for sending data to the action URL
formnovalidate formnovalidate Defines that form elements should not be validated when submitted
height pixels Defines the height of an <input> element
list datalist_id Specifies the <datalist> element that contains pre-defined options for an <input> element
max OR min autofocus Specifies the maximum OR minimum value
maxlength number Defines the maximum number of characters allowed in a text field
multiple multiple Specifies that a user can enter multiple values
name
value
text Defines the name & value of an <input> element
pattern regexp Specifies a regular expression that an <input> element's value is checked against
placeholder text Specifies a short hint that describes the expected value
readonly readonly Specifies that an input field is read-only
required required Specifies that an input field must be filled out before submitting the form
size number Specifies the width, in characters, of an <input> element
src URL Defines the URL of the image to display (only for type="image")
step number Specifies the legal number intervals for an input field
type button
checboxcolor
date
datetime
datetime-local
email
file
hidden
image
month
number
password
radio
range
reset
search
submit
tel
text
time
URL
week
Specifies the type <input> element to display
width pixels Specifies the width of an <input> element

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)