Forms are the primary way users interact with a website, allowing them to send data — searches, logins, contact info — to a server. The <form> tag acts as a container with two critical attributes: action (the URL where data is sent) and method (how data is sent — GET appends to URL for searches, POST hides in request body for passwords/private info). Common Form Elements <input type="text"> for single-line text, <input type="password"> to mask characters, <input type="checkbox"> for multiple selections, <input type="radio"> for single selection from a group (must share the same name), <textarea> for multi-line text, and <select> with <option> tags for dropdown menus. Labels & Validation Each input needs a <label> linked via the for/id pair — this improves usability (clicking label…
Key Takeaways
Every <input> needs a <label> for accessibility.
GET for searches (data in URL), POST for sensitive data (in body).
HTML5 validation: required, pattern, minlength — no JS needed.
<datalist> creates a combo box with filterable suggestions.
Use <fieldset> and <legend> to group related fields.