Skip to content

Button with href | Adding Href to Button example code

  • by

If JavaScript is allowed, set the window.location.href to create Button with href.

<input type="button" onclick="location.href='';" value="Go to Google" />

Instead of <input type="button"> in above example, you can also use <button>. The only difference is that the <button> element allows children.

The plain HTML way is to put it in a <form> wherein you specify the desired target URL in the action attribute.

<form action="">
    <input type="submit" value="Go to Google" />

HTML Button with href Example code

HTML example code


	<input type=button onClick="location.href='index.html'"
	value='click here'>



Button with href

Do comment if you have any doubts and suggestion on this HTML button tutorial.

Note: The All HTML Examples codes are tested on the Firefox browser and the Chrome browser.

OS: Windows 10

Code: HTML 5 Version

Leave a Reply

Your email address will not be published. Required fields are marked *