Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING BASH RUST

HTML Tutorial

HTML HOME HTML Introduction HTML Editors HTML Basic HTML Elements HTML Attributes HTML Headings HTML Paragraphs HTML Styles HTML Formatting HTML Quotations HTML Comments HTML Colors HTML CSS HTML Links HTML Images HTML Favicon HTML Page Title HTML Tables HTML Lists HTML Block & Inline HTML Div HTML Classes HTML Id HTML Buttons HTML Iframes HTML JavaScript HTML File Paths HTML Head HTML Layout HTML Responsive HTML Computercode HTML Semantics HTML Style Guide HTML Entities HTML Symbols HTML Emojis HTML Charsets HTML URL Encode HTML vs. XHTML

HTML Forms

HTML Forms HTML Form Attributes HTML Form Elements HTML Input Types HTML Input Attributes Input Form Attributes

HTML Graphics

HTML Canvas HTML SVG

HTML Media

HTML Media HTML Video HTML Audio HTML Plug-ins HTML YouTube

HTML APIs

HTML Web APIs HTML Geolocation HTML Drag and Drop HTML Web Storage HTML Web Workers HTML SSE

HTML Examples

HTML Examples HTML Editor HTML Quiz HTML Exercises HTML Website HTML Syllabus HTML Study Plan HTML Interview Prep HTML Bootcamp HTML Certificate HTML Summary HTML Accessibility

HTML References

HTML Tag List HTML Attributes HTML Global Attributes HTML Browser Support HTML Events HTML Colors HTML Canvas HTML Audio/Video HTML Doctypes HTML Character Sets HTML URL Encode HTML Lang Codes HTTP Messages HTTP Methods PX to EM Converter Keyboard Shortcuts

HTML Buttons


Buttons let users interact with a web page. They can submit forms, run JavaScript, or trigger different actions when clicked.


HTML Button

The HTML <button> element defines a clickable button.

By itself, the button does nothing until you add an action to it.

Example

<button>Click Me</button>
Try it Yourself »

Styling HTML Buttons

Buttons are often styled with CSS:

Example

<button class="mytestbtn">Green Button</button>
Try it Yourself »

Disabled Buttons

Use the disabled attribute to make a button unclickable:

Example

<button disabled>Disabled Button</button>
Try it Yourself »

Tip: Disabled buttons cannot be clicked and usually appear faded.


Button with JavaScript

You can run JavaScript when the user clicks a button using the onclick attribute:

Example

<button onclick="alert('Hello!')">Click Me</button>
Try it Yourself »

Note: You will learn more about JavaScript in our HTML JavaScript chapter.


Button Types

The type attribute defines what a button does when clicked. There are three button types:

  • type="button" - A normal clickable button (does nothing by default)
  • type="submit" - Submits a form
  • type="reset" - Resets all form fields
<button type="button">Normal Button</button>
<button type="submit">Submit</button>
<button type="reset">Reset</button>

Buttons are often used inside forms, which you will learn more about in a later chapter.

For now, just know that a submit button sends the form data to the server, while a reset button clears the form:

Example

<form action="/action_page.php">
  First name: <input type="text" name="fname">
  <button type="submit">Submit</button>
  <button type="reset">Reset Form</button>
</form>
Try it Yourself »

Note: You should always specify the type attribute. Inside a form, the default type is submit, and browsers may behave differently if the type is omitted.


HTML Button Reference

Tag Description
<button> Defines a clickable button

Tip: For a complete list of all HTML tags, visit our HTML Tag Reference.


×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.