HTML Forms Interview
Interview Q&A on form structure, common controls, validation basics, and accessibility.
1Purpose of
<form>?easyAnswer: Collects user input and submits data to server endpoint.
2Difference between GET and POST?medium
Answer: GET appends data to URL; POST sends data in request body.
3Why use
label with inputs?easyAnswer: Better accessibility and larger click target; bind using
for + input id.4Common input types?easy
Answer: text, email, password, number, date, checkbox, radio, file, submit.
5Use of
name attribute?easyAnswer: It is the key used in form submission payload.
6What does
required do?easyAnswer: Enforces browser-side mandatory field validation.
7
placeholder vs label?mediumAnswer: Placeholder is hint text; label identifies field and should not be skipped.
8How to group related fields?medium
Answer: Use
fieldset and legend.9What is client-side validation?medium
Answer: Browser checks input constraints before submit; still requires server-side validation.
10Interview best-practice summary?medium
Answer: Accessible labels, semantic grouping, proper types, and secure server validation.
Tricky Q&A (10 Questions)
11Default method if method attribute omitted:tricky
Answer: Correct answer: GET. Forms default to GET when method is not specified.
12Which pairs label with control correctly?tricky
Answer: Correct answer: label for=id matching input id. for/id association is the standard accessible pattern.
13Radio buttons in one group share:tricky
Answer: Correct answer: Same name attribute. Same name groups radio options.
14textarea content goes:tricky
Answer: Correct answer: Between opening and closing tags. textarea uses body text as default value.
15Which button type does NOT submit a form by default?tricky
Answer: Correct answer: button. type='button' has no default submit behavior.
16select multiple attribute allows:tricky
Answer: Correct answer: Several selected options. multiple enables multi-select list boxes.
17Placeholder vs label:tricky
Answer: Correct answer: Label is required for accessibility; placeholder is hint only. Never use placeholder as the only label.
18Hidden inputs are:tricky
Answer: Correct answer: Submitted but not shown. type='hidden' sends data without display.
19optgroup label attribute:tricky
Answer: Correct answer: Groups options under a heading. optgroup label names the group.
20CSRF tokens are often sent via:tricky
Answer: Correct answer: hidden input. Hidden fields commonly carry anti-CSRF tokens.