Create an HTML button that acts like a link

To create an HTML button that acts like a link, you can use the <button> tag and add an onclick attribute that redirects the user to a specific URL when the button is clicked. Here’s an example code snippet:

php
<button onclick="location.href='http://example.com';">Go to Example.com</button>

In this example, the button text is “Go to Example.com”, and the onclick attribute specifies the URL to redirect the user to when the button is clicked.

You can also use CSS to style the button to look like a link. Here’s an example CSS code snippet:

css
.button-link {
background: none;
border: none;
color: blue;
cursor: pointer;
text-decoration: underline;
}

In this example, the CSS class .button-link styles the button to have no background or border, blue text, and an underline text decoration. You can then apply this class to your button using the class attribute:

php
<button class="button-link" onclick="location.href='http://example.com';">Go to Example.com</button>

This will create a button that looks like a link and redirects the user to the specified URL when clicked.