HTML Button


<button> tag in HTML

The <button> tag is used to create button.

The difference between <button> tag and <input> tag is, in <button> tag text or images can be added.

Example

Try Yourself

autofocus attribute in <button> tag

The autofocus attribute is used to focus the specified html control by default when the page loads.

Example 1 - only one autofocus attribute

Try Yourself

If more than one autofocus attribute is used in a html document, only the first specified html control will be focused.

Example 2 - more than one auto focus attribute

Try Yourself

disabled attribute in <button> tag

The disabled attribute is used to disable the button.

User can not interact with the button.

Example

Try Yourself

<button> tag with image tag

Images can be added to the button tag.

Example 1 - Display icon in left side

Try Yourself

Example 2 - Display icon in right side

Try Yourself

Example - Difference between input type="button" and <button> tag

Try Yourself