📡 You're offline — showing cached content
New version available!
Quick Access
Tutorials HTML Fundamentals Forms Basics

Forms Basics

5 min read Quiz at the end
Forms collect user input. Always pair every input with a label using matching for and id attributes. Use method='POST' for sensitive data and set action to the URL that processes the submitted form data.

HTML Forms

<form action="/submit" method="POST">
    <label for="name">Name:</label>
    <input type="text" id="name" name="name" required>

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

    <button type="submit">Submit</button>
</form>

Always pair <label> with <input> using for and id.

Topic Quiz · 5 questions

Test your understanding before moving on

1. Which attribute associates a label with an input?
💡 label for="id" links to input id="id" — clicking the label focuses the input.
2. What does the required attribute do?
💡 required prevents form submission if the field is empty.
3. method="POST" vs method="GET"?
💡 GET appends data to the URL; POST sends data in the body (more secure for sensitive data).
4. What does the action attribute specify?
💡 action="/url" specifies where the form data is sent when submitted.
5. What does novalidate do on a form?
💡 novalidate disables browser built-in validation so you can use custom JavaScript validation.