The HTML enctype attribute
Quick answer
The HTML enctype attribute specifies how form data is encoded when submitted with POST. It is used on the <form> element.
Overview
The enctype attribute specifies how form data is encoded when submitted with POST. It applies to the <form> element.
Use multipart/form-data whenever the form contains a file <input type="file">.
Syntax
<form method="post" enctype="multipart/form-data"> … </form>
Values
| Value |
|---|
| application/x-www-form-urlencoded (default) | multipart/form-data | text/plain |
Best practices
- Use
method="post"for submissions that change data andmethod="get"for searches and filters. - Set
enctype="multipart/form-data"when the form uploads files. - Prefer native validation over
novalidate; only skip validation deliberately. - Always process and re-validate the submission on the server.
Frequently asked questions
What does the enctype attribute do?
Sets the encoding of submitted form data.
What is the difference between GET and POST?
GET appends the data to the URL (good for searches and bookmarkable results); POST sends it in the request body (used for actions that change data).
How do I let a form upload files?
Which elements use the enctype attribute?
It is an element-specific attribute, used on the <form> element.