HTML Button Tag

This tag is used to create clickable buttons on the web page.


<button type="button">PRESS</button>

result:

The most common way to use the HTML button is with javascript onclick events and other actions.




Examples HTML buttons with javascript onclick event

code:



<button onclick="this.style.background='red';">PRESS</button>


result:






code:



<button onclick="alert('You clicked on the button');">PRESS</button>


result:






code:



<button onclick="window.location.href='https://itpresent.com'"> PRESS </button>

result: