HTML and CSS Reference
In-Depth Information
Figure 2.3. Each web browser vendor implements a different style when presenting input validation errors to the
user. As more websites begin to use HTML5 form validation, users will become more familiar with the standard
style of error message displayed by their browser of choice.
Now, let's look at three additional attributes: autofocus , required , and place-
holder .
The autofocus, required, and placeholder attributes
autofocus attribute 6.0
4.0
10.0
11.0
5.0
5.0 [ * ]
required attribute 10.0
4.0
10.0
10.0
placeholder attrib-
ute
4.0
4.0
10.0
11.6
5.0
* Indicates partial support
The autofocus attribute is self-explanatory; it allows you to define which input element
should receive focus when the page loads. The required attribute is also straightfor-
ward—it allows you to define that a field must contain input from the user in order to
be valid. You'll learn much more about HTML5 form validation later in the chapter. The
placeholder attribute allows you to define a piece of text that will appear in a field
when it's empty and inactive. As soon as the user types in the field, the placeholder text
will be cleared and replaced with the user's input. This is illustrated in figure 2.4 .
 
 
Search WWH ::




Custom Search