<input> Tag — HTML Technical Interview Questions & Answers
A form control for many kinds of user input.
<input> Tag
- A form control for many kinds of user input.
- <input> is a form control. HTML uses this tag so the browser (and screen readers) know what the piece is, not only how it looks.
- Board: <input name="roll" type="number"> Put it in body. Check it in the browser. Attributes go on the opening tag.
- Trap: no label. CSS can still style it — don’t pick a tag only because of default italics.
- Interview: name the tag, one attribute if it has a famous one (href, src, alt, for, type), one mistake.
Technical Interview Tip: <input>: a form control. Example: <input name="roll" type="number">
Code Examples for <input> Tag
<input> Tag — working example
<label for="email">Email</label>
<input id="email" name="email" type="email" required autocomplete="email" />
<label for="when">Date</label>
<input id="when" name="when" type="date" />
<label for="level">Level</label>
<input id="level" name="level" type="range" min="0" max="10" value="5" />
<label for="tone">Color</label>
<input id="tone" name="tone" type="color" value="#2563eb" /><input> Tag — hTML5 input types give native keyboards, validation, and pickers — still pair with labels.
How to Explain <input> Tag to an Interviewer
What is the <input> tag?
a form control <input name="roll" type="number">
One common mistake?
no label