How to create an HTML push-button link

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

Using the code below, you can create a push-button link. If you want the link to go to a web page other than Computer Hope, change the URL https://www.computerhope.com/ to the web page you want to open.

Tip

The code below is entered between the <body> and </body> HTML tags.

<form>
<input type="BUTTON" value="Homepage" onclick="window.location.href='https://www.computerhope.com/'">
</form>

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 contained within single quotes as well.

Example

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

Note

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 bottom or top of the browser if blocked. A button titled Allow blocked content may be available to click. Clicking this button should allow the code to be executed and the button to work on your web page.