Just wondering if there is a way to get a HTML element to link to a location without wrapping it in an
tag?
Bu
Here's a solution which will work even when JavaScript is disabled:
<form action="login.html">
<button type="submit">Login</button>
</form>
The trick is to surround the button with its own <form>
tag.
I personally prefer the <button>
tag, but you can do it with <input>
as well:
<form action="login.html">
<input type="submit" value="Login"/>
</form>
<form action="portfolio.html">
<button type="link" class="btn btn-primary btn-lg">View Work</button>
</form>
I just figured this out, and it links perfectly to another page without having my default link settings over ride my button classes! :)