The element in HTML4
HTML4 input elements use the type attribute to specify the data type.HTML4 provides following types:
Type | Description |
---|---|
ext | A free-form text field, nominally free of line breaks. |
assword | A free-form text field for sensitive information, nominally free of line breaks. |
heckbox | A set of zero or more values from a predefined list. |
adio | An enumerated value. |
ubmit | A free form of button initiates form submission. |
ile | An arbitrary file with a MIME type and optionally a file name. |
mage | A coordinate, relative to a particular image's size, with the extra semantic that it must be the last value selected and initiates form submission. |
idden | An arbitrary string that is not normally displayed to the user. |
elect | An enumerated value, much like the radio type. |
utton | A free form of button which can initiates any event related to button. |
Following is the simple example of using labels, radio buttons, and submit buttons:
...
<form action="http://example.com/cgiscript.pl" method="post">
<p>
<label for="firstname">first name: label>
<input type="text" id="firstname"><br />
<label for="lastname">last name: label>
<input type="text" id="lastname"><br />
<label for="email">email: label>
<input type="text" id="email"><br>
<input type="radio" name="sex" value="male"> Male<br>
<input type="radio" name="sex" value="female"> Female<br>
<input type="submit" value="send"> <input type="reset">
p>
form>
...
The element in HTML5
Apart from the above mentioned attributes, HTML5 input elements introduced sevral new values for the type attribute. These are listed below.
NOTE: Try all the following example using latest version of Opera browser.
Type | Description |
---|---|
atetime | A date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601 with the time zone set to UTC. |
atetime-local | A date and time (year, month, day, hour, minute, second, fractions of a second) encoded according to ISO 8601, with no time zone information. |
ate | A date (year, month, day) encoded according to ISO 8601. |
onth | A date consisting of a year and a month encoded according to ISO 8601. |
eek | A date consisting of a year and a week number encoded according to ISO 8601. |
ime | A time (hour, minute, seconds, fractional seconds) encoded according to ISO 8601. |
umber | This accepts only numerical value. The step attribute specifies the precision, defaulting to 1. |
ange | The range type is used for input fields that should contain a value from a range of numbers. |
This accepts only email value. This type is used for input fields that should contain an e-mail address. If you try to submit a simple text, it forces to enter only email address in format. | |
rl | This accepts only email value. This type is used for input fields that should contain a URL address. If you try to submit a simple text, it forces to enter only URL address either in http://www.example.com format or in http://example.com format. |
The
HTML5 introduced a new element
Comments (0)