Skip to: content, navigation

by Ian Lloyd

button (HTML element)

Spec
Depr. Empty Version
No No HTML 4
Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Buggy Full Full Full

Example

Here, the phrase including the em element is a clickable button:

<form>
  <button>I am <em>really</em> sure I want to proceed</button>
</form>
Type
inline element
Contains
block-level elements, inline elements (except a, input, select, textarea, label, button, and iframe)
Contained by
block-level elements, inline elements (except a, input, select, textarea, label, button, and iframe)

Description

The button form control is an attempt at improving the humble "submit" button (input type="submit"), which can only contain one line of text (the value attribute), and places certain limitations on the possibilities for CSS styling. It’s possible to wrap the button element around a whole collection of HTML elements, encapsulating the entire area as a single, clickable element. Of course, it’s not necessarily wise to cram too much into the button, but some helpful effects are possible. For example, this control could be used to add emphasis to part of the button text, as Figure 1 shows.

Figure 1. Formatting part of the button text differently from the rest Part of the button text is formatted differently - not possible with a standard submit input

By default, the button will act as a "submit" button, but we can set it, via the type attribute, to be a "reset" or a simple "button" (with no default action—we’d need to use JavaScript to add behavior in this case).

Use This For …

This control is used in cases where a simple "submit" button isn’t capable of containing the information required, or where CSS styling requirements can’t be met by a simple "submit" button.

Compatibility

IE5.5Buggy
6.0Buggy
7.0Buggy
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

This element type isn’t particularly well supported and has limited practical value.

Rendering of the button and its contents varies, but Internet Explorer appears to provide the worst rendering.

In this Section

Related Reading

User-contributed notes

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters