Trusted answers to developer questions

How to insert a button in HTML

Free System Design Interview Course

Many candidates are rejected or down-leveled due to poor performance in their System Design Interview. Stand out in System Design Interviews and get hired in 2024 with this popular free course.

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.

RELATED TAGS

web
html

CONTRIBUTOR

Celeste
Copyright ©2024 Educative, Inc. All rights reserved
Did you find this helpful?