<input> element

The input element is used to collect user input. The default input element is a text field:

 
<!DOCTYPE HTML>
<html>
<head>
<title>Example</title>
</head>
<body>
      <form method="post" action="http://yourServer/form">
            <p>
                  <label for="fave">Item: 
                     <input autofocus id="fave" name="fave" />
                  </label>
            </p>
            <p>
                  <label for="name">Name: <input disabled id="name" name="name" /></label>
            </p>
            <button>Submit Vote</button>
      </form>
</body>
</html>
  
Click to view this demo.

Using the input Element for Text Input

There are additional attributes for the text type input.

AttributeDescriptionNew in HTML5
dirnamedirectionality of the text.No
listSets the id of a datalist element that provides values for this element.Yes
maxlengththe maximum number of characters that user can enter.No
patternSpecifies a regular expression for input validation.Yes
placeholderSpecifies a hint to the userYes
readonlyMakes the text box read-onlyNo
requiredSpecifies that the user must enter a valueYes
sizeSpecifies the width of the element in the number of characters.No
valueSpecifies the initial valueNo
Home 
  HTML CSS Book 
    HTML  

input:
  1. <input> element
  2. input element max size
  3. input text field size
  4. input text field initial value
  5. input text field placeholders(gray text)
  6. Using a Data List
  7. Read-Only input text field
  8. Disabled Text Boxes
  9. input element for password input
  10. Using the input Element to Create Buttons
Related: