Skip to main content
Crowdfunding
Python + AI for Geeks
Practice

button Tag

The <button> tag represents a clickable button used for interacting with the user on a web page.

For example, clicking the button could send data to a server, navigate to another page, or trigger other actions.


Example of Using button Tag
<button>Click Me!</button>

The code above creates a button with the text "Click Me!".


Adding Functionality to a Button

A button on its own is a simple clickable element. To make it perform specific actions, you need to use a programming language like JavaScript.

For instance, to display an alert message when the button is clicked, you can write:

Display Alert Message on Click
<button onclick="alert('The button was clicked!')">Click Me!</button>

Follow the highlighted parts of the code to input your version.

Want to learn more?

Join CodeFriends Plus membership or enroll in a course to start your journey.