HTML and CSS Reference
In-Depth Information
2. The ability to provide an implementation for this feature dynamically using JavaScript.
Even where it is possible to detect a feature is missing, it may not be possible to provide an
implementation.
Although it is often trivial to provide both of these features in your own code, it is always
preferable to use well tested existing libraries where possible. The most popular library for
detecting supported features is Modernizr, and can be found at http://modernizr.com/ .
With Modernizr in place, feature detection is as simple as this:
if (Modernizr.canvas) {
// do nothing
} else {
// provide implementation
}
In addition to feature detection, Modernizr also contains a large list of polyfill implement-
ations that can be utilized, or you can write your own.
HTML5 also offers native support for two entirely new form elements:
Progress : this provides a native implementation of a progress bar that can be updated
through changes to the progress bar attributes.
Meter : this provides a scalar measurement within a defined range.
These new elements will prove enormously useful when fully implemented, until then
however it is likely you will need to rely on alternatives offered by libraries such as jQuery
UI.
New Attributes on Input types
In addition to the new input types, a large number of new attributes are supported on input
types. Attributes are used to control how an element works.
Many of these attributes are provided to support native HTML validation, these include:
• required : this indicates that a value is mandatory for the field in order to submit the form.
• maxlength : this is used on text based input fields to specify the maximum length of the
input.
• min and max : these are used on number , date and range based input fields to specify
minimum and maximum values.
• pattern : these are used whenever input must conform to a regular expression pattern.
Most browsers provide default implementations for types such as email .
Search WWH ::




Custom Search