Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. HTML Tag Dictionary
  3. <button>

<button>

The button element creates a clickable button. Unlike the button-type variants of input, it can contain HTML inside the element, allowing you to create flexible buttons that include icons and decorative content.

Syntax

<!-- Form submit button -->
<button type="submit">Submit</button>

<!-- General-purpose button (handled by JavaScript) -->
<button type="button">Click</button>

<!-- Disabled button -->
<button type="button" disabled>Unavailable</button>

<!-- Button containing HTML -->
<button type="button">
  <img src="icon.png" alt=""> Search
</button>

Attribute List

AttributeDescription
typeSpecifies the button's behavior. There are three options: submit (submits the form), button (general-purpose), and reset (resets the form).
nameSpecifies the button's name. Used to identify which button was pressed when a form has multiple submit buttons.
valueSpecifies the value sent to the server when the form is submitted.
disabledGrays out the button and prevents it from being clicked. This is a boolean attribute that requires no value.
formSpecifies the id of the form to associate the button with. Use this when placing a button outside its form element.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Button Element</title>
  <style>
    button {
      padding: 8px 16px;
      margin: 4px;
      border-radius: 4px;
      cursor: pointer;
    }
    .btn-primary { background: #3498db; color: #fff; border: none; }
    .btn-danger  { background: #e74c3c; color: #fff; border: none; }
  </style>
</head>
<body>

  <form id="myForm" action="/send" method="post">
    <p>
      <label for="name">Name: <input type="text" id="name" name="name"></label>
    </p>
  </form>

  <!-- Works as a submit button for the form outside it via the form attribute -->
  <button type="submit" form="myForm" class="btn-primary">Submit</button>

  <!-- General-purpose button (handled by JavaScript) -->
  <button type="button" onclick="alert('Hello!')">Greet</button>

  <!-- Disabled button -->
  <button type="button" class="btn-danger" disabled>Delete (Disabled)</button>

</body>
</html>

Result

A blue "Submit" button, a "Greet" button, and a grayed-out "Delete (Disabled)" button are displayed. Clicking "Greet" shows an alert, and "Delete (Disabled)" cannot be clicked.

Rendered HTML Preview
Name: Submit Greet Delete (Disabled) Click to show alert Not clickable

Notes

The key advantage of the button element is that its content can include HTML. You can place not just text but also icon images, SVGs, and more inside it, giving you great design flexibility. CSS styles can also be applied freely.

If you omit the type attribute, the button defaults to submit behavior inside a form. Always specify type="button" explicitly for buttons intended only for JavaScript event handling. Omitting it can cause unintentional form submissions.

The combination of name and value is useful when placing multiple submit buttons in a single form — it lets the server determine which button was clicked. For other input controls related to buttons, see the input (buttons & misc) page.

Browser Compatibility

Chrome Chrome
49+
Supported in all versions
Firefox Firefox
57+
Supported in all versions
Safari Safari
18+
Supported in all versions
Edge Edge
80+
11 or earlier ×
IE IE
11 or earlier ×
Opera Opera
48 or earlier ×
iOS Safari iOS Safari
18+
Supported in all versions
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .