HTML <form> tag
- closing tag
- required
- void element
- no
- lives inside
- <body>
- typically holds
- inputs, labels, and a submit button
Where it goes
Around every <input>, <label>, <select> and <button> that belong to that one submission.
Example
<form action="/submit" method="post">
<input type="text" name="query">
<button>Submit</button>
</form>Open this example in the editor →
Common mistakes
- Leaving fields outside any <form>. They show on screen but are never sent anywhere.
- Leaving off action. The form then sends to the current page's own address, which is sometimes intended and often just forgotten.
- Using get for a form with a password. get puts every value in the address bar, where browser history and server logs can see it.