How to create an HTML push-button link

Updated: 05/21/2018 by Computer Hope
HTML push button

Use the code below to create a push-button link. If you want the link to go to a web page other than Computer Hope, change the URL (uniform resource locator) to the web page you want to open.


The code below is entered between the <body> and </body> HTML (hypertext markup language) tags.

<input type="BUTTON" value="Homepage" onclick="window.location.href=''">

The type attribute must be set to "BUTTON" to define as a clickable button on the web page. The value attribute sets the text displayed on the button itself. The onclick attribute sets the action performed when the button is clicked. In this case, we want the button click to open the page defined after the "window.location.href=' code. The web page address must be enclosed in single quotes too.


Some Internet browsers, like Internet Explorer, may block the code above from running, resulting in the button not working when clicked. A message similar to "Internet Explorer restricted this web page from running scripts or ActiveX controls" may appear at the top or bottom of the browser if blocked. A button titled Allow blocked content may be available to click. Clicking this button should allow the code to execute and the button to work on your web page.


Click the button below to see an example of how this code works.