HTML
CSS
JavaScript
jQuery
PHP
SQL
WordPress
HTML Reference

Quick Reference

The input tag specifies an input field where the user can enter data in a form to send to the site owner.

				
					<form>
    <label for="first_name">First name:</label>
    <input type="text" id="first_name" name="first_name">

    <label for="last_name">Last name:</label>
    <input type="text" id="last_name" name="last_name">

    <label for="email">Email:</label>
    <input type="email" id="email" name="email">

    <input type="submit" value="Submit">
</form>
				
			



Types of Inputs

<input type="button">
<input type="checkbox">
<input type="color">
<input type="date">
<input type="datetime-local">
<input type="email">
<input type="file">
<input type="hidden">
<input type="image">
<input type="month">
<input type="number">
<input type="password">
<input type="radio">
<input type="range">
<input type="reset">
<input type="search">
<input type="submit">
<input type="tel">
<input type="text"> (default)
<input type="time">
<input type="url">
<input type="week">

Attributes

The following attributes can be used within the input tag.

AttributeValueDescription
acceptfile_extension
audio/*
video/*
image/*
media_type
Specifies a filter for what file types the user can pick from the file input dialog box (only for type=”file”)
alttextSpecifies an alternate text for images (only for type=”image”)
autocompleteon
off
Specifies whether an <input> element should have autocomplete enabled
autofocusautofocusSpecifies that an <input> element should automatically get focus when the page loads
checkedcheckedSpecifies that an <input> element should be pre-selected when the page loads (for type=”checkbox” or type=”radio”)
dirnameinputname.dirSpecifies that the text direction will be submitted
disableddisabledSpecifies that an <input> element should be disabled
formform_idSpecifies the form the <input> element belongs to
formactionURLSpecifies the URL of the file that will process the input control when the form is submitted (for type=”submit” and type=”image”)
formenctypeapplication/x-www-form-urlencoded
multipart/form-data
text/plain
Specifies how the form-data should be encoded when submitting it to the server (for type=”submit” and type=”image”)
formmethodget
post
Defines the HTTP method for sending data to the action URL (for type=”submit” and type=”image”)
formnovalidateformnovalidateDefines that form elements should not be validated when submitted
formtarget_blank
_self
_parent
_top
framename
Specifies where to display the response that is received after submitting the form (for type=”submit” and type=”image”)
heightpixelsSpecifies the height of an <input> element (only for type=”image”)
listdatalist_idRefers to a <datalist> element that contains pre-defined options for an <input> element
maxnumber
date
Specifies the maximum value for an <input> element
maxlengthnumberSpecifies the maximum number of characters allowed in an <input> element
minnumber
date
Specifies a minimum value for an <input> element
minlengthnumberSpecifies the minimum number of characters required in an <input> element
multiplemultipleSpecifies that a user can enter more than one value in an <input> element
nametextSpecifies the name of an <input> element
patternregexpSpecifies a regular expression that an <input> element’s value is checked against
placeholdertextSpecifies a short hint that describes the expected value of an <input> element
readonlyreadonlySpecifies that an input field is read-only
requiredrequiredSpecifies that an input field must be filled out before submitting the form
sizenumberSpecifies the width, in characters, of an <input> element
srcURLSpecifies the URL of the image to use as a submit button (only for type=”image”)
stepnumber
any
Specifies the interval between legal numbers in an input field
typebutton
checkbox
color
date
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
valuetextSpecifies the value of an <input> element
widthpixelsSpecifies the width of an <input> element (only for type=”image”)

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.

HTML
CSS
JavaScript
jQuery
PHP
SQL
WordPress

Why 1SMARTchicken?

This site was built and is maintained to benefit my autistic son.
See More →

My Son's Name is Johnny

He was diagnosed as autistic quite late, at age four...
His story

Buy Me a Coffee

Thanks for your support!

Feedback

If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.