w3resource

HTML button tag and element

1. HTML button element is used to represent a button in an HTML form.

2. button element is used to create submit or reset button.

3. button element starts with a <button> tag and ends with a </button> tag.

Syntax

<button>Some text or image</button> 

Category

HTML button element belongs to HTML forms.

Whether both start and end tags are required

yes.

Can contain

HTML button element can contain inline elements except for A, INPUT, SELECT, TEXTAREA, LABEL, BUTTON, and IFRAME. Block-level elements except for FORM, ISINDEX, and FIELDSET.

Can reside within

HTML button element can reside within inline elements and other block level elements.

Attributes

Identifiers

id, class.

language information and text direction

lang, dir.

Title

Title.

Style

Style.

Disabled input controls

disabled.

Tabbing navigation

tabindex.

Access keys

accesskey.

Events

onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmousemove, onmouseout ,onkeypress, onkeydown, onkeyup.

Supported doctypes

HTML 4.01 strict, HTML 4.01 transitional, HTML 4.01 frameset.

Example of using HTML button element

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>HTML button tag example - HTML tutorial | w3resource</title>
</head>
<body>
<form name="button_example" action="html-button-tag-example.html" >
<input type="button" name="mybutton" value="Button">
</form>
</body>
</html>

Result

html button element

View this example in a separate browser window

HTML button tag example.

Previous: HTML input tag and element
Next: HTML select, option and optgroup tag and element

Test your Programming skills with w3resource's quiz.



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/html/button/HTML-button-tag-and-element.php