Http Methods in HTML
? HTTP Methods and Their Relation to HTML Forms
HTML itself doesn’t define HTTP methods, but when submitting forms or interacting with servers, HTTP methods specify the action type.
Common HTTP Methods Used with HTML
| Method | Purpose | Usage in HTML Forms |
|---|---|---|
| GET | Retrieve data from the server | Default method; form data sent in URL query string (?name=value) |
| POST | Send data to the server | Sends form data in the request body (more secure and supports large data) |
| PUT | Replace or update resource | Not supported directly by HTML forms (needs JavaScript or APIs) |
| DELETE | Delete a resource | Not supported directly by HTML forms |
| HEAD | Get headers only | Not supported by HTML forms |
| OPTIONS | Check allowed methods | Not supported by HTML forms |
How to Use HTTP Methods in HTML Forms
<form action="/submit" method="GET"> <!-- form inputs --> <button type="submit">Send GET</button></form><form action="/submit" method="POST"> <!-- form inputs --> <button type="submit">Send POST</button></form>GET: Useful for search forms or where bookmarking URL is helpful
POST: Best for sensitive data or file uploads
Note on Other HTTP Methods
To use methods like
PUTorDELETE, web apps usually rely on JavaScript (AJAX/fetch API) or backend frameworks — not native HTML forms.
Want a demo of how to send POST data with an HTML form or how to use JavaScript to send PUT/DELETE requests?