button (HTML element)

Depr. Empty Version
No No HTML 4
Browser support (more…)
IE5.5+ FF1+ SA1.3+ OP9.2+ CH2+
Buggy Full Full Full Full


<button name="string" type=" { button | reset | submit } " value="value">


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 should 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).


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

  <button value="proceed">I am <em>really</em>
  sure I want to proceed</button>

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.


Internet Explorer Firefox Safari Opera Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
Buggy Buggy Buggy Buggy Full Full Full Full Full Full Full Full Full Full Full Full Full

Rendering of the button and its contents varies, but Internet Explorer presents both the worst rendering and functionality issues. IE will not submit a form with a button unless there is a type attribute set to "submit" (it should default to "submit" rather than have to be told). This is easy enough to put right, then, but there are bigger problems with the data that is submitted. In IE versions 6 and earlier, if you have several buttons with the same name but with three different values and text displayed inside the button to the user (see code sample below), it does not matter which button is pressed, data from all three are passed through, rather than just the button that is pressed (IE7, IE8 only submit the data from the button pressed).

<div><button name="buttonChoice" value="btn1" 
 type="submit">Button 1 Text</button></div>
<div><button name="buttonChoice" value="btn2" 
 type="submit">Button 2 Text</button></div>
<div><button name="buttonChoice" value="btn3" 
 type="submit">Button 3 Text</button></div>

Using the markup above in a simple test page that submits to itself using a method of "get", IE versions 6 and earlier will send the following (carriage returns added to make it fit - would normally appear in the address bar in one continual line):


This certainly makes using the button element tricky with IE. Assuming that catering for IE6 is important for your audience - and it still is for a significant number of web sites - you may be better off avoiding this element entirely, opting instead for a simple input of type "submit". For more information about the what data is submitted by IE refer to the button value compatibility section.

In this Section

User-contributed notes

Related Products