HTML and CSS Reference
In-Depth Information
the transmission. It is up to the server to either decode the parameters
or pass them, still encoded, to the application.
The standard encoding format is the Internet Media Type application/x-
www-form-urlencoded. You can change that encoding with the optional
enctype
attribute in the
<form>
tag. The only optional encoding formats
currently supported are multipart/form-data and text/plain.
The multipart/form-data alternative is required for those forms that con-
tain file-selection fields for upload by the user. You should use the text/
plain format in conjunction with a mailto URL in the
action
attribute for
sending forms to an email address rather than a server. Unless your
forms need file-selection fields or you must use a mailto URL in the
ac-
tion
attribute, you probably should ignore this attribute and simply rely
upon the browser and your processing server to use the default encod-
ing type. [
File-selection controls, 9.5.1.3
]
9.2.2.1. The application/x-www-form-urlencoded encoding
The standard encodingapplication/x-www-form-urlencodedconverts any
spaces in the form values into a plus sign (
+
), nonalphanumeric charac-
ters into a percent sign (
%
) followed by two hexadecimal digits that are
the ASCII code of the character, and the line breaks in multiline form
data into
%0D%0A
.
The standard encoding also includes a name for each field in the form.
(A
field
is a discrete element in the form, whose value can be nearly
anything from a single number to several lines of textthe user's address,
for example.) If there is more than one value in the field, the values are
separated by ampersands.
For example, here's what the browser sends to the server after the user
fills out a form with two input fields labeled
name
and
address
; the former
field has just one line of text, and the latter field has several lines of
input:
name=O'Reilly+Media&address=1005+Gravenstein+Highway+North%0D%0A
Sebastopol,%0D%0ACA+95472