HTML Forms

Forms collect user input and send it to a server.

HTML
<form action="/register" method="post">
    <label for="nm">Name:</label>
    <input type="text" id="nm" name="name" placeholder="Your name" required><br>

    <label for="em">Email:</label>
    <input type="email" id="em" name="email"><br>

    <label for="pw">Password:</label>
    <input type="password" id="pw" name="password" minlength="8"><br>

    Gender:
    <input type="radio" name="gender" value="F" id="f"><label for="f">Female</label>
    <input type="radio" name="gender" value="M" id="m"><label for="m">Male</label><br>

    <input type="checkbox" id="t" name="terms"> <label for="t">I accept the terms</label><br>

    <label for="br">Branch:</label>
    <select id="br" name="branch">
        <option>Computer</option><option>IT</option><option>E&TC</option>
    </select><br>

    <textarea name="about" rows="3" cols="30" placeholder="About you"></textarea><br>
    <button type="submit">Register</button>
</form>



Gender:



Input Types

text, password, email, number, tel, url, date, time, color, range, file, checkbox, radio, search, hidden, submit and reset.

GET vs POST

GETPOST
Data in the URL (?name=Asha)Data in the request body
Can be bookmarked; length limitedNo size limit; not bookmarkable
Use for searches and filtersUse for logins and sensitive data
Track your progress through the HTML course