asp.net.ph

Skip Navigation LinksHome > Abakada: Back to Basics > Language References > HTML Elements > INPUT Element

<INPUT Element | INPUT Object


Creates various types of form input controls.HTML 2, 3.2, 4, 4.01, 5
button checkbox color date datetime-local
email file hidden image month
number password radio range reset
search submit tel text time
url week

Remarks

The <input> HTML element is used to create a wide variety of interactive controls for web-based forms.

How an <input> works depends on the value of its type attribute,

If no type attribute is specified, the control defaults to a single-line textbox.

NOTE: Only the <input> start tag must be present. The element has no end tag.

Attributes

The <input> element supports the following attributes, in addition to global attributes common to all HTML elements.

AttributeValueDescription
dateDefines the shape of the bullets used for each list item.
acceptfile_extension, audio/*, video/*, image/*, media_typeSpecifies 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, offSpecifies 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/plainSpecifies how the form-data should be encoded when submitting it to the server (for type="submit" and type="image")
formmethodget, postDefines 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, framenameSpecifies 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
maxnumberSpecifies the maximum value for an input element
maxlengthnumberSpecifies the maximum number of characters allowed in an input element
minnumber, dateSpecifies 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
popovertargetelement_idSpecifies which popover element to invoke (only for type="button")
popovertargetactionhide, show, toggleSpecifies what happens to the popover element when you click the button (only for type="button")
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, anySpecifies 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, weekSpecifies the type input element to display
valuetextSpecifies the value of an input element
widthpixelsSpecifies the width of an input element (only for type="image")

Example

The following examples illustrate use of the different types of the INPUT element.

<form>
   Name <input value="enter your name here">
</form>
Name
<form>
   Password <input type="password">
</form>
Password
<form>Color 
   <input type="radio" name="color" value="0" checked>Red
   <input type="radio" name="color" value="1">Green
   <input type="radio" name="color" value="2">Blue
</form>
Color Red Green Blue
<form>Assets 
   <input type="checkbox">House
   <input type="checkbox">Car
   <input type="checkbox">Whatever
</form>
Assets House Car Whatever
<form>
   <input type="submit" value="Send">
   <input type="reset" value="Reset">
</form>

See Also

BUTTON, SELECT, TEXTAREA



Check out related books at Amazon

© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note