Name

<BUTTON> — NN n/a IE 4 HTML 4

Synopsis

<BUTTON>...</BUTTON>

End Tag: Required

The BUTTON element is patterned after the INPUT element (of types button, submit, and reset) but carries some extra powers, particularly when used as a submit-type button. Content for the button’s label goes between the element’s start and end tags, rather than being assigned as an attribute. Other elements can be used to generate the label content, including an IMG element if so desired (although client-side image maps of such images are strongly discouraged by the W3C). Although you can assign a style sheet to a BUTTON element, you can also wrap the label content inside an element (such as a SPAN) and assign or override style rules just for that content. Both style sheet mechanisms permit the button label to use custom fonts and styles.

When a BUTTON element is assigned a TYPE of submit, the browser submits the button’s NAME and VALUE attributes to the server as a name/value pair, like other form elements. No special form handling is conveyed by a BUTTON when other types are specified.

In theory, a BUTTON element should be embedded within a FORM element. In practice, IE 4 has no problem rendering a free-standing BUTTON element. This might be acceptable when no related form elements (such as text boxes) need to be referenced by scripts associated with the button. Some scripting shortcuts (passing form object references as parameters) simplify the scripted interactivity between form elements.

The W3C ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.