HTML and CSS Reference
In-Depth Information
maxlength
This attribute indicates the maximum content length that can be entered in a
text form control (
type="text"
). The maximum number of characters allowed differs from
the visible dimension of the form control, which is set with the
size
attribute.
min
This HTML5 attribute should be set to a numeric value that is the low range allowed
in the form control. The
max
attribute sets the high range.
multiple
This HTML5 Boolean attribute, when set to
true
, indicates that multiple values
are allowed for the field.
name
This attribute allows a form control to be assigned a name to set as the name/value
pair value sent to the server. Traditionally, this value was also used for reference by a
scripting language, but using the
id
value is more appropriate. However, given that
browsers sometimes favor the older syntax, both may often be used and set to the same
value, with some limitations, particularly with radio buttons.
pattern
This HTML5 attribute specifies a regular expression against which the field should
be validated. The
title
attribute should be provided when this attribute is used, to give an
indication of what is an acceptable pattern and what isn't.
placeholder
This HTML5 attribute specifies a short bit of text that is used to help the user
figure out what type of information to fill in for a form control. Likely, the text will be
placed in the field and cleared upon focus.
readonly
This attribute prevents the form control's value from being changed. Form
controls with this attribute set might receive focus from the user but not permit the user to
modify the value. Because it receives focus, a
readonly
form control will be part of the
form's tabbing order. The control's value will be sent on form submission. This attribute can
be used only with
<input>
when
type
is set to
text
or
password
. The attribute also is
used with the
textarea
element.
required
The presence of this HTML5 Boolean attribute indicates that the form field must
be set in order for form submission to proceed. User agents that understand this should set
the CSS pseudo-class
:invalid
when the field goes into error.
size
This attribute indicates the visible dimension, in characters, of a text form control
(
type="text"
). This differs from the maximum length of content, which can be entered in a
form control set by the
maxlength
attribute.
src
This attribute is used with image form controls (
type="image"
) to specify the URL of
the image file to load.
step
This HTML5 attribute defines the step in which values can take; for example, by twos
(2, 4, 6…) or tens (10, 20, 30…). It is generally used in range controls.
tabindex
This attribute takes a numeric value that indicates the position of the form control
in the tabbing index for the form. Tabbing proceeds from the lowest positive
tabindex
value to the highest. Negative values for
tabindex
will leave the form control out of the
tabbing order. When tabbing is not explicitly set, the browser tabs through items in the