Skip to: content, navigation

by Ian Lloyd

enctype (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
No HTML 2
enctype=" { application/x-www-form-urlencoded | multipart/form-data | text/plain } "

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>

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.

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

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full

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

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters