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.