EN
HTML - button that acts like link
0
points
In this article, we would like to show you how to create a button element that acts like a link in HTML.
Quick solution:
// ONLINE-RUNNER:browser;
<form action="https://dirask.com/posts/DZ3Jep" target="_blank">
<button type="submit">Click me!</button>
</form>
or:
// ONLINE-RUNNER:browser;
<a href="https://dirask.com/posts/DZ3Jep" target="_blank">
<button>Click me!</button>
</a>
1. Using button
inside form
element
In this section, we
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<body>
<form action="https://dirask.com/posts/DZ3Jep" target="_blank">
<button type="submit">
Click me!
</button>
</form>
</body>
</html>
Note:
You can also use
<input type="submit">
as a<button type="submit">
replacement.
2. Using button
inside a
element
In this section, we use button element inside the <a>
tag to create a button that acts like a link.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<body>
<a href="https://dirask.com/posts/DZ3Jep" target="_blank">
<button>
Click me!
</button>
</a>
</body>
</html>
3. Using CSS
Go to the following article to see how to style the link
element to make it look like a button: