Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML5 Form Elements

HTML5 Form Elements


HTML5 New Form Elements

HTML5 has the following new form elements:

**Note:** Not all browsers support the new HTML5 form elements, but you can use them; even if a browser does not support the form attributes, they can still be displayed as regular form elements.


HTML5 Element

The element specifies a list of options for an input field.

The attribute specifies that a form or input field should have autocomplete functionality. When a user starts typing in an autocomplete field, the browser should display the filling options in that field:

Use The list attribute of the element is associated with the element.

Example

The element usespredefined values:

<

input

list

=

"

browsers

"

<

datalist

id

=

"

browsers

"

<

option

value

=

"

Internet Explorer

"

<option value="Firefox">
<option value="Chrome">
<option value="Opera">
<option value="Safari" datalist>

Try it »


HTML5 Element

The element is used to provide a reliable way to verify users.

The tag specifies a key-pair generator field for forms.

When the form is submitted, two keys are generated, one private and one public.

The private key is stored on the client, and the public key is sent to the server. The public key can later be used to verify the user's client certificate.

This element has been deprecated and is no longer recommended; alternatives include:

  1. Generate keys in JavaScript using the Web Cryptography API

  2. Use a dedicated cryptography library

Example

A form with a keygen field:

<form action="demo_keygen.asp" method="get">

Username:

<input type="text" name="usr_name">

Encryption:

<

keygen

name

=

"

security

"

<

input

type

=

"

submit

"

form

Try it »


HTML5 Element

The element is used for different types of output, such as calculations or script output:

Example

Displaying the result of a calculation in the element:

<form oninput="x.value=parseInt(a.value)+parseInt(b.value)" 0>
<input type="range" id="a" value="50">

100 +

<

input

type

=

"

number

"

id

=

"

b

"

value

=

"

50

"

=

<

output

name

=

"

x

"

for

=

"

a b

"

output

form

Try it »


HTML5 New Form Elements

tag Description
The tag defines a list of options. Use this element together with the input element to define the possible values for the input.
The tag specifies a key-pair generator field for forms.
The tag defines different types of output, such as the output of a script.