Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How to create HTML button that acts like a link?

I want to create an HTML button that acts as a link. So, when you click the button, it redirects to a page. I would like it to be as accessible as possible.
I would also like it so there aren't any extra characters or parameters in the URL.
How can I achieve this?
by

5 Answers

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

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

If necessary, set CSS display: inline; on the form to keep it in the flow with the surrounding text. Instead of <input type="submit"> in above example, you can also use <button type="submit">. The only difference is that the <button> element allows children.

You'd intuitively expect to be able to use <button href=" //google.com"> analogous with the <a> element, but unfortunately no, this attribute does not exist according to HTML specification.
Bharatv4tg1
In the event that you are utilizing an inside structure, add the trait type="reset" alongside the catch component. It will forestall the structure-activity.
<button type="reset" onclick="location.href='http example.com'">
www.example.com
</button>
sandhya6gczb
sample code to do this

<form>
<button formaction="url">Go </button>
</form>
wills556
For inside structure, add the trait type="reset" alongside the catch component. It will forestall the structure-activity.
<button type="reset" onclick="location.href='http writemyessays.us'">
www.writemyessays.us
</button>
swedishcasino
you should have to use code and WordPress is better then now .
www.officeplus.ae

Login / Signup to Answer the Question.