HTML and CSS Reference
In-Depth Information
include a maxlength attribute you should also provide some visible hint to your visitors to let
them know how many characters the control will accept.
min : Specifies the minimum value allowed for the control, either a number, a date, or a time. This
is new in HTML5 and only for use with a number input or any of the date input types. If a max
attribute is also present, the value of min can't exceed the value of max .
multiple : A Boolean attribute that, when present, indicates that multiple values can be entered.
This is new in HTML5 and typically appears in combination with a datalist element (covered
later in this chapter).
pattern : This is new to HTML5 and allows an author to define a regular expression against
which the input's value can be checked. For example, pattern="[1-5]" specifies that the
input's value must be an integer between 1 and 5, and pattern="[A-Za-z]" accepts only
upper- and lowercase letters (no numbers or other symbols). Far more complex patterns are
possible. See for a good starting point with regular expressions.
placeholder : This new attribute introduced in HTML5 allows the author to include a short text
hint to advise the user on what value is expected for the input. The browser hides the placeholder
label automatically when the control is in focus (or when the user begins typing) and, if there was
no value entered in its place, the placeholder reappears when the field loses focus.
readonly : Specifies that the control may only display an initial value and can't be modified. This
differs from disabled in that a read-only control can still receive focus and its value is still
submitted with the form.
required : This Boolean attribute is new to HTML5 and indicates that the control must have a
value in order to submit the form.
size : Specifies the width of a rendered text control as a number of characters, so the actual
rendered width will depend on the font size. By default, most browsers will display text controls
around 20 or 25 characters wide.
src : Specifies the source URL of an image file (only for input type="image" ).
step : This is new in HTML5 and specifies the number intervals for a numeric input ( input
type="number" ). For example, given the attribute step="3" , the number control will accept -3,
0, 3, 6, 9, and so on, stepping in multiples of 3.
tabindex : Specifies, by number, the control's position in the tabbing order when a user cycles
through active controls using the Tab key. Typically (and by default), the tabbing order follows the
source order, with each stroke of the Tab key advancing focus to the next active control in the
document. The tabindex attribute can change that natural order if needed. For example, a
control with tabindex="1" appears first in the tabbing order, regardless of where it might occur
in the document's source order.
type : Specifies the type of form control the input element represents. The default input type is
text if the attribute is missing or if its value isn't recognized. Older browsers that may not
recognize the new input types introduced in HTML5 will gracefully degrade to a text input.
Search WWH ::

Custom Search