HTML & CSS Interview Question #22

What is an HTML form?

HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner

Quick Interview Answer

An HTML form groups controls used to collect and submit user input. The form element can specify where data is submitted with action and which HTTP method is used with method.

Detailed Explanation

An HTML form groups controls used to collect and submit user input. The form element can specify where data is submitted with action and which HTTP method is used with method.

Form controls should have meaningful names because those names identify submitted values. Labels, validation, appropriate input types, and server-side validation are important parts of a usable and secure form.

Code Example

<form action="/account/login" method="post">
    <label for="email">Email</label>
    <input id="email"
           name="email"
           type="email"
           required>

    <button type="submit">Sign in</button>
</form>