HTML5 input autofocus, html5 input required.


 

HTML5 input autofocus, html5 input required.

In this tutorial, you will see the use of autofocus and required attribute of input tag.

In this tutorial, you will see the use of autofocus and required attribute of input tag.

HTML5 input autofocus, html5 input required.

Introduction:

Here we will introduce you to about the autofocus and required attribute of input tag.

Type Attribute:
Attribute Value Description
autofocus
required
autofocus
required
Automatically focus when page load.
User must fill this field.

Declaration Syntax :

                           <input  type="value" attribute/>

Example of <input> in HTML5:

Code:
InputTag.html
<!doctype html >
<html>
<head>
<title>Title of document.</title>
</head>
<body><h2>Input tag.</h2>
<h2>Implementation of&nbsp; attributes of input tag. </h2>
<form ><table >
<tr>
<td style="width: 198px">Name</td>
<td><input type="Text" ></td>
</tr>
<tr>
<td style="width: 198px">Autofocus attribute</td>
<td><input type="Text" autofocus></td>
</tr>
<tr>
<td style="width: 198px">Required</td>
<td><input type="Text" required></td>
</tr>
<tr>
<td style="width: 198px"><input type="reset" value="Reset" ></td>
<td><input type="submit" value="Submit" ></td>
</tr>
</table></form>
</body>
</html>
Output:

Download this code

Difference Between HTML5 and HTML4.01:

The input tag is available in both HTML5 and HTML4.01. But there is some attribute in HTML5, that is not supported by HTML4.01.

Ads