The <input> tag creates a field for users to enter data in a form. The type attribute defines the behavior and appearance of the input.
text – Default single-line inputpassword – Hides typed charactersemail – Requires valid email formatnumber – Only accepts numberscheckbox – Multiple options toggleradio – One selection from manysubmit – Sends the formreset – Resets the form fieldsdate – Calendar inputtime – Time selectionfile – Upload filesrange – Slider for numeric inputcolor – Color picker input<input type="date">
<input type="color">placeholder: Shows hint inside the fieldrequired: Makes input mandatorydisabled: Grays out and disables the fieldreadonly: Prevents editingvalue: Sets a default value<input type="text" placeholder="Your Name" required>To make radio buttons mutually exclusive, give them the same name:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> FemaleWrap inputs with <label> or link using for/id for better accessibility:
<label for="email">Email:</label>
<input type="email" id="email" name="email">Customize inputs using CSS to match your design system.
Build a mini form with the following fields:
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name" placeholder="Your name" required><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email"><br><br>
Gender:
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female"> Female<br><br>
<button type="submit">Submit</button>
</form>Ask the AI if you need help understanding or want to dive deeper in any topic