HTML Form Methods and Data Encoding
GET for retrieval
GET form submission encodes entries into the destination URL query. Use it for retrieval such as search, not state-changing actions or sensitive values. Query data can appear in history and logs. The following is an illustrative form; do not activate its submit button in a playground.
<form action="/search" method="get"> <label> Query <input name="q" value="web forms"> </label> <button type="button">Search (demo)</button></form>The entry q=web forms would be encoded as q=web+forms. No request is made by this example.
POST and URL encoding
POST normally carries entries in the request body. The default enctype is application/x-www-form-urlencoded, which encodes text entries as name=value pairs. POST is not encryption; use HTTPS and server validation.
<form action="/feedback" method="post"> <label> Topic <input name="topic" value="A&B"> </label></form>The default encoding is URL-encoded; the value would become A%26B.
Multipart for files
Use method=post and enctype=multipart/form-data when sending file content. Multipart separates entries into parts; the browser generates the boundary. text/plain is useful for debugging but is ambiguous and not a good production format. The example does not upload anything.
<form action="/attachments" method="post" enctype="multipart/form-data"> <label> Attachment <input type="file" name="attachment"> </label> <button type="button">Upload (demo)</button></form>The form declares multipart encoding and contains a named file input.
Common mistakes and practice
HTML does not send JSON automatically. JavaScript can serialize data differently, but that is beyond this lesson. Do not use GET for passwords or private submissions; POST alone does not make data confidential. Practice predicting the encoded value of a space or ampersand.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Form Methods and Data Encoding — Knowledge Check
Apply the control concepts taught in this lesson.
Where does a GET form normally place entries?
What is the default POST form encoding?
Which encoding carries file content?
Does POST encrypt the form body?
What does A&B become as a URL-encoded value?