enctype (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Full Full Full Full Full

Syntax

enctype=" { application/x-www-form-urlencoded | multipart/form-data | text/plain } "

Description

The enctype attribute’s purpose is to indicate how form data should be encoded prior to it being sent to the location defined in the action attribute. By default, form data is encoded so that spaces are converted to "+" symbols, and special characters—for example, apostrophes, percentage and other symbols, and so on—are converted to their ASCII HEX equivalents.

Example

In this example, the enctype attribute tells the browser to send form data unencoded:
<form action="address.php" method="get" enctype="text/plain">
  <div>
    <label for="txtname">Full Name:</label>
    <input type="text" name="txtname" id="txtname"/>
  </div>
  <div>
    <label for="txtcontacttel">Contact Tel:</label>
    <input type="text" name="txtcontacttel" id="txtcontacttel"/>
  </div>
  <div>
    <input type="submit" name="cmdSubmit" id="cmdSubmit"
        value="Send personal details"/>
  </div>
</form>

Value

The default value (which is assumed, and doesn’t need to be set explicitly) is "application/x-www-form-urlencoded". It ensures that all characters are encoded before they’re sent to the server. The other possible values are "multipart/form-data", which is required when you’re using forms that have a file upload control (it ensures that no character conversion takes place, and transfers form data as a compound MIME document), and "text/plain", which converts spaces to "+" symbols, but doesn’t HEX-encode special characters such as apostrophes.

Compatibility

Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full Full

It causes no compatibility issues, and has excellent support across all tested browsers.

User-contributed notes

There are no comments yet.

Related Products