HTML and CSS Reference
In-Depth Information
Required Attributes
The form element doesn't require any attributes. Previous versions of HTML required an action attribute
to specify the form handler URL, but in HTML5 that attribute can appear on another control such as a
submit button, or it can be omitted entirely and the current document will act as the default form handler.
Optional Attributes
accept-charset : Specifies the accepted character encoding for data submitted through the
form. When the attribute is missing, the accepted character encoding is assumed to be the same
as that of the parent document.
action : Specifies the URL of the form handler, which is the script or application that will process
the submitted form data.
autocomplete : This attribute is new to HTML5 and specifies whether browsers should be
allowed to automatically complete the controls within the form. This attribute only accepts the
values on or off , with on being the default value if the attribute is missing.
enctype : Specifies the type of encoding to use when the form is submitted, one of three possible
values: application/x-www-form-urlencoded (the default), multipart/form-data (if the
submitted form will include files uploaded via an input type="file" control), or text/plain
(which performs no additional encoding).
method : Specifies which HTTP method will be used to submit the form data, either get or post .
The method defaults to get if this attribute is missing.
novalidate : Indicates that the form data should not be validated when submitted, bypassing any
field requirements or formatting rules, though any JavaScript or server-side validation might still
be performed. This Boolean attribute is new in HTML5, and doesn't require a value, but you can
provide a value in XHTML syntax as novalidate="novalidate" .
Previous versions of HTML included an accept attribute for the form element that
indicated the file types accepted by the form via an input type="file" control,
covered later in this chapter. This attribute is obsolete for form elements in HTML5, but
can instead appear on the input element itself.
The input Element
Most common form controls are instances of the input element, with each type of input control indicated
by a corresponding type attribute. The input element is styled as inline by default so several can appear
on the same line. It's also a void element, so it can hold neither text nor any other elements. A browser
replaces the input element with a functional form control when it renders the page. This is a diverse
element that performs many different duties. It also has loads of optional attributes, though some are only
for use with certain input types.
Search WWH ::

Custom Search