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.
The plain HTML way is to put it in a wherein you specify the desired target URL in the
action
attribute.
If necessary, set CSS display: inline;
on the form to keep it in the flow with the surrounding text. Instead of in above example, you can also use
. The only difference is that the
element allows children.
You'd intuitively expect to be able to use analogous with the
element, but unfortunately no, this attribute does not exist according to HTML specification.
If CSS is allowed, simply use an which you style to look like a button using among others the appearance property (it's only not supported in Internet Explorer).
Go to Google
a.button {
-webkit-appearance: button;
-moz-appearance: button;
appearance: button;
text-decoration: none;
color: initial;
}
Or pick one of those many CSS libraries like Bootstrap.
Go to Google
If JavaScript is allowed, set the window.location.href
.
Instead of in above example, you can also use
. The only difference is that the
element allows children.