HTML enctype Attribute

HTML enctype Attribute: This attribute defines how the form-data should be encoded when submitted to the server. This type of attribute can be used only if method = “POST”.

Element: The enctype attribute is associated with <form> element only.

Attribute Value: This attribute contains three value which is listed below:

application/x-www-form-urlencoded

It is the default value. It encodes all the characters before sent to the server and converts spaces into + symbols and special character into its hex value.

multipart/form-data

This value does not encode any character.
text/plain: This value convert spaces into + symbols but special characters are not converted.

HTML enctype Attribute

This attribute can be applied to <form> element.

Syntax: <form enctype = “value”> 



Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Safari
  • Opera
  • Internet Explorer

enctype Attribute Example

<!DOCTYPE html>
<html>
<body>
<form action="/action_page_binary.asp" method="post" enctype="multipart/form-data">
  First name: <input type="text" name="fname"><br>
  Last name: <input type="text" name="lname"><br>
  <input type="submit" value="Submit">
</form>
</body>
</html>

Output:

HTML enctype attribute