Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to create an HTML button that acts like a link?
    primarykey
    data
    text
    <p>I would like to create an HTML button that acts like a link. So, when you click the button, it redirects to a page. I would like it to be as accessible as possible.</p> <p>I would also like it so there aren't any extra characters, or parameters in the URL.</p> <p>How can I achieve this?</p> <hr> <p>Based on the answers posted so far, I am currently doing this:</p> <pre><code>&lt;form method="get" action="/page2"&gt; &lt;button type="submit"&gt;Continue&lt;/button&gt; &lt;/form&gt; </code></pre> <p>but the problem with this is that in <a href="http://en.wikipedia.org/wiki/Safari_%28web_browser%29" rel="noreferrer">Safari</a> and <a href="http://en.wikipedia.org/wiki/Internet_Explorer" rel="noreferrer">Internet&nbsp;Explorer</a>, it adds a question mark character to the end of the URL. I need to find a solution that doesn't add any characters to the end of the URL.</p> <p>There are two other solutions to do this: Using JavaScript or styling a link to look like a button.</p> <p>Using JavaScript:</p> <pre><code>&lt;button onclick="window.location.href='/page2'"&gt;Continue&lt;/button&gt; </code></pre> <p>But this obviously requires JavaScript, and for that reason it is less accessible to screen readers. The point of a link is to go to another page. So trying to make a button act like a link is the wrong solution. My suggestion is that you should use a link and <a href="https://stackoverflow.com/questions/710089/how-do-i-make-an-html-link-look-like-a-button">style it to look like a button</a>.</p> <pre><code>&lt;a href="/link/to/page2"&gt;Continue&lt;/a&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload