<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>
Using the input Element for Text Input
There are additional attributes for the text type input.
Attribute | Description | New in HTML5 |
---|---|---|
dirname | directionality of the text. | No |
list | Sets the id of a datalist element that provides values for this element. | Yes |
maxlength | the maximum number of characters that user can enter. | No |
pattern | Specifies a regular expression for input validation. | Yes |
placeholder | Specifies a hint to the user | Yes |
readonly | Makes the text box read-only | No |
required | Specifies that the user must enter a value | Yes |
size | Specifies the width of the element in the number of characters. | No |
value | Specifies the initial value | No |
Home
HTML CSS Book
HTML
HTML CSS Book
HTML
input:
- <input> element
- input element max size
- input text field size
- input text field initial value
- input text field placeholders(gray text)
- Using a Data List
- Read-Only input text field
- Disabled Text Boxes
- input element for password input
- Using the input Element to Create Buttons
Related: