Earlier we covered some of the new features of HTML 5, such as canvas, audio and video. In this article we'll cover many of the useful new elements that the specification brings to the table. Please remember, though, that HTML 5 is a work in progress, and not fully supported by many browsers yet.
There are many new elements added to HTML 5. These elements are divided into form elements and other markup elements.
Form Elements
Let's start with the form elements. Form elements as you know them from previous versions of HTML (specifically 4.01) are still supported, but new elements and attributes have been added to address the limitations that web developers have been facing. However, browser support for HTML 5 form elements is still limited. Here is an example that contains some of the new form features (only a portion of the code is shown):
The key points to address are:
The name field has a required attribute (has a red border, as you'll see in the output below). Also, there is a placeholder attribute that directs the user to what to write in the textbox.
The type of the e-mail address is "email," and its property of autocomplete is set to off. If the user types an email address with the wrong format, the textbox will have a red border, and a tooltip with a message is displayed.
The type of the phone number is "tel."
The type of the web site is url. The same condition applies here as the email address if the user types a url in the wrong format.
The score is of type "range" with both minimum and maximum values. The output (with some information filled in) is as follows: