NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<button> (Form Button)


This element defines a nameable region known as a button, which can be used together with scripts.

Standard Syntax


<button
accesskey="key"
class="class name(s)"
dir="ltr | rtl"
disabled
id="unique alphanumeric identifier"
lang="language code"
name="button name"
style="style information"
tabindex="number"
title="advisory text"
type="button | reset | submit"
value="button value"
</button>

Attributes Defined by Internet Explorer


contenteditable="false | true | inherit" (5.5)
datafld="name of column supplying bound data" (4)
dataformatas="html | text" (4)
datasrc="id of data source object supplying data" (4)
hidefocus="true | false" (5.5)
language="javascript | jscript | vbs | vbscript" (4)
unselectable="on | off" (5.5)

Standard Events


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

Events Defined by Internet Explorer


onactivate, onafterupdate, onbeforeactivate, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onbeforeupdate, onblur, oncontextmenu, oncontrolselect, oncut, ondeactivate, ondragenter, ondragleave, ondragover, ondrop, onerrorupdate, onfilterchange, onfocus, onfocusin, onfocusout, onhelp, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onselectstart

Element Specific Attributes


accesskey

This attribute specifies a keyboard navigation accelerator for the element. Pressing ALT or a similar key in association with the specified key selects the anchor element correlated with that key.

datafld
This attribute specifies the column name from the data source object that supplies the bound data that defines the information for the <button> element's content.

dataformatas
This attribute indicates whether the bound data is plain text or HTML.

datasrc
This attribute indicates id of the data source object that supplies the data that is bound to the <button> element.

disabled
This attribute is used to disable the button.

name
This attribute is used to define a name for the button so that it can be scripted by older browsers or used to provide a name for submit buttons when there is more than one in a page.

tabindex
This attribute uses a number to identify the object's position in the tabbing order.

type
Defines the type of button. According to the HTML 4.01 specification, by default the button is undefined. Possible values include button, reset, and submit, which are used to indicate the button is a plain button, reset button, or submit button respectively.

value
Defines the value that is sent to the server when the button is pressed. This might be useful when using multiple submit buttons that perform different actions to indicate which button was pressed to the handling CGI program.

Example


<button name="Submit" value="Submit" type="Submit">Submit Request</button>

<button type="button" onclick="doSomething()">Click This Button</button> <<button type="button">
<img src="polkadot.gif" alt="Polkadot"></button>

Compatibility


HTML 4, 4.01
Internet Explorer 4, 5, 4.5, 5.5, 6
Netscape 6, 7
Opera 5-7

Notes


It is illegal to associate an image map with an <img> tag that appears as the content of a button element.

The HTML 4.01 specification reserves the data-binding attributes datafld, dataformatas, and datasrc for future use. They were dropped from XHTML but Internet Explorer does support them.

Developers may want to consider using the markup <input type="submit"> instead of a <button> tag for complete browser backward compatibility.

(X)HTML Elements
CSS Properties
Previous: break Next: caption
< Home | About | Chapters | Examples | Errata | Reference | Site Map >