The <input>
tag in HTML is used to create various form elements. Apart from the type
attribute, it supports several other properties. Here's an overview:
-
name
Attribute:- Defines the name of the input element. Used when submitting form data.
-
value
Attribute:- Sets the initial value of the input.
-
disabled
Attribute:- Disables the input element, preventing user interaction.
-
readonly
Attribute:- Specifies that the input field is read-only.
-
placeholder
Attribute:- Provides a short hint that describes the expected input.
-
autofocus
Attribute:- Automatically focuses on the input element when the page loads.
-
required
Attribute:- Indicates that the input must be filled out before submitting the form.
-
autocapitalize
Attribute:- Controls capitalization of text.
-
autocomplete
Attribute:- Enables or disables browser auto-completion.
-
autocorrect
Attribute:- Controls automatic spelling correction.
-
spellcheck
Attribute:- Specifies whether the browser should check the spelling of the text.
-
size
Attribute:- Specifies the visible width of the input, in characters.
-
maxlength
Attribute:- Defines the maximum number of characters allowed in the input.
-
minlength
Attribute:- Specifies the minimum number of characters required in the input.
-
width
andheight
Attributes:- Sets the width and height of the input element.
-
class
Attribute:- Specifies one or more class names for styling.
-
style
Attribute:- Defines inline CSS styles for the input element.
onclick
,onchange
,oninput
, etc.:- Event attributes to execute JavaScript code on various events.
These properties enhance the functionality and appearance of the <input>
element. Choose and customize them based on your specific form requirements and styling preferences.