HTML and CSS Reference
In-Depth Information
formaction
: This attribute is new to HTML5 and overrides the form's
action
attribute in defining
the control's handler (only for
button type="submit"
). The attribute's value is the URL of the
form handler where the data is sent when a user submits the form.
formenctype
: This is a new attribute in HTML5 and overrides the form's
enctype
attribute. It
specifies how the data should be encoded before it's sent to the server, but only when submitted
by the button bearing this attribute (and only for
button type="submit"
). The
formenctype
attribute only accepts the values
application/x-www-form-urlencoded
,
multipart/form-
data
, or
text/plain
.
formmethod
: This is new to HTML5 and overrides the form's method for sending data to the form
handler. The two possible values are
get
and
post
(only for
button type="submit"
).
formnovalidate
: A new Boolean attribute in HTML5, this allows a form to be submitted while
bypassing the form's validation (only for
button type="submit"
). Indicating this on a
button
instead of for the entire form allows some buttons to bypass validation while others don't. For
example, a “save” button might submit a partially completed form to let users save their progress,
but without going through the validation process the form will undergo when it's finally submitted
at the end.
formtarget
: This is new to HTML5 and overrides the form's
target
attribute, which specifies
the target window to use when the form is submitted. This attribute can only appear on a
button
type="submit"
and its value is the name of the target window or frame, or one of the keywords
_blank
,
_self
,
_parent
, or
_top
.
value
: Specifies the value of the button to be submitted along with the form data. This value is
only submitted if the button itself is used to submit the form; another submit button or submitting a
form by pressing “Enter” won't submit this value.
keygen
The
keygen
element generates a matched pair of encryption keys when the form is submitted—one public,
sent to the form handler for use by the website or application, the other private and stored locally in the
browser. This mathematically matched pair of keys allows the browser and the original website or
application to securely identify each other on subsequent visits.
Netscape first introduced this element years ago and other browsers (apart from Internet Explorer) copied
Netscape's implementation, but
keygen
wasn't part of any official HTML specification until it was included
in HTML5. Microsoft has stated that they have no plans to implement
keygen
support in Internet
Explorer—and have even asked for it to be taken out of the HTML5 specification—so this type of form
encryption won't work with any past, current, or future version of IE. You may prefer to use a more
universally supported encryption method, such as Transport Layer Security (TLS) or Secure Sockets Layer
(SSL).
We won't explain all the ins and outs of public key cryptography here, as it's well beyond the scope of this
book (see
wikipedia.org/wiki/Public-key_cryptography
for a brief introduction, if you're still
curious). And because the
keygen
element is so specialized and obscure, you can have a long and fruitful