HTML form Tag enctype Attribute Tutorial

In this section, we will see what enctype attribute is and how to use it.

What is enctype Attribute in HTML <form> Tag?

Encoding the data that we send from a document (webpage) to a server increases the security and helps to protect data when they are being submitted.

The enctype attribute is used in HTML <form> element to set the encoded type for the form data when they are being submitted to a server.

Use this attribute when the HTTP method the form is using to send the data to a server is set to POST.

In the rest of this section, we’ll see what values we could use for this attribute.

HTML enctype Attribute in <form> Tag Syntax:

<form method = “POST” enctype = “application/x-www-form-urlencoded | multipart/form-data | text/plain”> </form>

<form> Tag enctype Attribute Values

In the list below you can see the values that could be used for the enctype attribute:

Name

Description

application/x-www-form-urlencoded

This is the default value and when used, all the characters of the form data will be encoded before being sent.

multipart/form-data

If in the form we have file as well (<input type= “file”>), then this is the value that should be set for the formenctype attribute.

text/plain

If we use this value, it means the form data should not be encoded! For security reasons, this is not recommended at all.

Example: using enctype attribute in HTML <form> tag

See the Pen using enctype attribute in HTML <form> tag by Omid Dehghan (@odehghan) on CodePen.

Facebook
Twitter
Pinterest
LinkedIn

Top Technologies