INPUT tag in HTML

130
Mr. Coder | 17-Sep-2024
Introduction


<input> tag is used to specify/display the input field, where users can provide some input in the web page.

There are different types of input types which are as follows -

  1. button
  2. checkbox
  3. color
  4. date
  5. datetime-local
  6. email
  7. file
  8. hidden
  9. image
  10. month
  11. number
  12. password
  13. radio
  14. range
  15. reset
  16. search
  17. submit
  18. tel
  19. text
  20. time
  21. url
  22. week

The type is defined as an attribute in the <input /> tag. 

<input type="text" />


Output
  1. button
    <input type="button" value="submit" />


  2. checkbox
    <input type="checkbox" />


  3. color
    <input type="color" />


  4. date
    <input type="date" />


  5. datetime-local
    <input type="datetime-local" />


  6. email
    <input type="email" />


  7. file
    <input type="file" />


  8. hidden
    <input type="hidden" />


  9. image
    <input type="image src="https://common-content.thegyanva.com/images/logo.png" />


  10. month
    <input type="month" />


  11. number
    <input type="number" />


  12. password
    <input type="password" />


  13. radio
    <input type="radio" />


  14. range
    <input type="range" />


  15. reset
    <input type="reset" />


  16. search
    <input type="search" />


  17. submit
    <input type="submit" />


  18. tel
    <input type="tel" />


  19. text
    <input type="text" />


  20. time
    <input type="time" />


  21. url
    <input type="url" />


  22. week
    <input type="week" />

The mentioned list is the code and output example of different types of input tags.

Attributes
acceptfile types like audio/*, video/* for only type="file"
altalternate text for type="image"
autocompleteon/off
autofocusfor input element to automatically focus on page load
checkedfor type="checkbox" and type="radio"
disabledto diable the element
formid of the form to which the input belongs
maxlengthmaximum number of characters allowed in the input
minlengthminimum number of characters allowed in the input
namename of the element
patternregexp - regular expression for input matching
placeholdershort hint to specify the element's expectation
readonlyfor making the element read only
requiredmakes the element required before submitting the form
srcurl of the image. Only for type="image"
typetype of element as shown in the above section
valuevalue of the input
Comments
Load more comments.
Please Login or Sign up to comment.
logo
facebook youtube