🔥Limited Offer: Get 50% OFFon AI & Full Stack Courses🔥
Back to HTML Notes
Topic #44

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>

Styling HTML Buttons

Buttons are often styled with CSS:

Example

<button class="mytestbtn">Green Button</button>

Disabled Buttons

Use the disabled attribute to make a button unclickable:

Example

<button disabled>Disabled Button</button>

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>

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>

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
Defines a clickable button

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

Want to go beyond the notes?

Join CodingNow 2.0's HTML course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

HTML Buttons – FAQs

Quick answers about learning HTML Buttons in HTML.

This free note from CodingNow 2.0 explains HTML Buttons in HTML — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every HTML topic on CodingNow 2.0, including HTML Buttons, is 100% free with no signup required.
With focused practice, most students grasp HTML Buttons in 1–3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) — expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now