HTML Input tag

Example A simple HTML form with two input fields and one submit button: <form action="form_action.asp" method=&...

Example

A simple HTML form with two input fields and one submit button:
<form action="form_action.asp" method="get">
  First name: <input type="text" name="fname" /><br />
  Last name: <input type="text" name="lname" /><br />
  <input type="submit" value="Submit" />
</form>


Definition and Usage

The <input> tag is used to select user information.
An input field can vary in many ways, depending on the type attribute. An input field can be a text field, a checkbox, a password field, a radio button, a button, and more.

Browser Support


The <input> tag is supported in all major browsers.

Differences Between HTML and XHTML

In HTML the <input> tag has no end tag.
In XHTML the <input> tag must be properly closed.

Tips and Notes

Tip: Use the <label> tag to define labels for input elements.

Optional Attributes

DTD indicates in which DTD the attribute is allowed. S=Strict, T=Transitional, and F=Frameset.

Attribute Value Description DTD
accept list_of_mime_types A comma-separated list of MIME types that indicates the MIME type of the file transfer.Note: Only used with type="file" STF
align top
texttop
middle
absmiddle
baseline
bottom
absbottom
Deprecated. Use styles instead.
Defines the alignment of text following the image. Note: Only used with type="image"
TF
alt text Defines an alternate text for the image.Note: Only used with type="image" STF
checked checked  Indicates that the input element should be checked when it first loads.Note: Used with type="checkbox" and type="radio" STF
disabled disabled Disables the input element when it first loads so that the user can not write text in it, or select it. Note: Cannot be used with type="hidden" STF
maxlength number Defines the maximum number of characters allowed in an input field.Note: Only used with type="text" or type="password" STF
name field_name Defines a unique name for the input element.Note: This attribute is required with type="button", type="checkbox", type="file", type="hidden", type="image", type="password", type="text", and type="radio" STF
readonly readonly Indicates that the value of this field cannot be modified. Note: Only used with type="text" or type="password" STF
size number_of_char Defines the size of the input element.Note: Cannot be used with type="hidden" STF
src URL Defines the URL of the image to display.Note: Only used with type="image" STF
type button
checkbox
file
hidden
image
password
radio
reset
submit
text
Indicates the type of the input element. The default value is "text"
Note: This is not a required attribute, but we think you should include it. If omitted, IE 5.5 will still display a text field, but Netscape 4.7 will not.
STF
value value For buttons, reset buttons and submit buttons: Defines the text on the button.For image buttons: Defines the symbolic result of the field passed to a script.
For checkboxes and radio buttons: Defines the result of the input element when clicked. The result is sent to the form's action URL.
For hidden, password, and text fields: Defines the default value of the element.
Note: Cannot be used with type="file"
Note: This attribute is required with type="checkbox" and type="radio"
STF

Standard Attributes

id, class, title, style, dir, lang, xml:lang, tabindex, accesskey

Event Attributes

onfocus, onblur, onselect, onchange, onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout, onkeypress, onkeydown, onkeyup
Name

ADO,131,ASP,3,C++,61,CORE JAVA,1,CSS,115,HTML,297,index,5,JAVASCRIPT,210,OS,47,PHP,65,SAD,53,SERVLETS,23,SOFTWARE ENGINEERING,245,SQL,71,TCP/IP,1,XHTML,9,XML,18,
ltr
item
Best Online Tutorials | Source codes | Programming Languages: HTML Input tag
HTML Input tag
Best Online Tutorials | Source codes | Programming Languages
https://www.1000sourcecodes.com/2012/05/html-input-tag.html
https://www.1000sourcecodes.com/
https://www.1000sourcecodes.com/
https://www.1000sourcecodes.com/2012/05/html-input-tag.html
true
357226456970214079
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content