How to insert a button in HTML

The <button> tag in HTML defines a clickable button.

Syntax

The general syntax is:

<button>Button Name</button>
svg viewer

Inside a <button> element you can put the following content:

Adding Text

You can add text to the HTML Button.

For example, to create a submit button you can write:

<button type="button">Submit</button>

Adding Image

You can put an image in HTML Button.

For example, to create a image button write:

<button><img src="image url"></button>

HTML Attributes

HTML button have various attributes.

Syntax

The general syntax for adding attributes to the html button is:


<button type="button" attribute-name>Button Name</button>

Disabled

The disabled attribute makes the button unusable and unclickable.

Autofocus

The autofocus attribute specifies that the button should automatically get focus when the page loads.

Free Resources

Copyright ©2024 Educative, Inc. All rights reserved