HTML5 is the new generation of HTML. After the release of the first version of HTML, a lot of changes have been incorporated in HTML time and again, which lead to the introduction of HTML5. HTML5 has many new features added to it, like functions for embedding audio, video, graphics etc. Apart from the features mentioned above, there are many others, one of which includes several new elements and attributes for forms. This tutorial introduces you to some of the basic form elements in HTML5.
The Final Output as obtained in Google Chrome and Mozilla Browsers is shown below:
Please Note:The hover effect given to text fields and to the button, shows only in Mozilla. Other than that the output obtained for both Chrome and Mozilla browsers is the same.
Firstly, we have given a set of code for our background, which has been displayed below.
|
form, fieldset, legend, ol, li {
|
Limitations on Different Browsers:
|
/* The gradient effect shows in Google, Mozilla(version 3.6 and above) and IE(linear gradient only) browsers.*/
form#payment legend
form#payment > fieldset > legend:before
|
We have provided backgrounds to our text fields. Since the whole form follows a particular format, We have used "ol" and "li" tags for the same. Following code helps us to do the same, for both the base and the name of the text field (for 'card type' heading).
|
form#payment fieldset fieldset legend
{ color: #111111; font-size: 13px; font-weight: normal; padding-bottom: 0; } form#payment ol li |
The next few set of lines in the codes, have been used, especially for the Card details block. For example, with the help of below mentioned lines, we can change the background of the three card options, which is not given, as of now.
|
form#payment ol ol li { background: none; border: none; float: left; } |
The set of instructions given below, has been used for giving style to the field names.
|
form#payment label
{ float: left; font-size: 13px; width: 110px; } form#payment fieldset fieldset label
form#payment label[for=visa]
form#payment label[for=amex]
|
There are text areas for the various fields. The following code has been used to give the desired effects(like the hover effect) to the text fields. In HTML 5, we can specify 'input' types. Like for example, if we specify input type as 'radio', then that particular form element / field will be recognised as group of radio buttons, if input type is specified as 'submit', then that particular form element / field will be recognised as 'submit' button. Defining these input types are covered in the syntax / code / styles below.
|
/* The rounded corners effect does not show in IE browsers.*/
form#payment input[type=radio]
|
The code stated above, is simply for the second section with all the card details.
|
/* The rounded corners effect does not show in IE browsers.*/ form#payment button
/* The hover effect shows only in Google Chrome Browsers. */
|
This last piece of code, specified above, is for the button used in the Form. Hover effect has also been given for the same.
Thus, with the help of this Tutorial, you can manage a very basic form in HTML5.
Tags: HTML5 form, HTML5 form elements