Horje

How to add HTML <button> autofocus Attribute

A button with autofocus.

Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that a button should automatically get focus when the page loads.

Browser Support

The numbers in the table specify the first browser version that fully supports the attribute.

Syntax

<button type="button" autofocus>

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The button autofocus attribute</h1>

<button type="button" autofocus onclick="alert('Hello world!')">Click Me!</button>

</body>
</html>

Output should be:

How to add HTML <button> autofocus Attribute




Type:
html
Category:
Web Tutorial
Sub Category:
HTML Tag
Uploaded by:
Admin