how to make a button link to another page in html

In HTML, you can use the <a> (anchor) tag to create a button that links to another page. Here’s an example:

<a href=”http://www.example.com” class=”button”>Visit Website</a>

The href attribute specifies the link’s destination, which in this case is “http://www.example.com”.

You can also use the button tag to create a button that links to another page. Here’s an example:

<button type=”button” onclick=”location.href=’http://www.example.com'”>Visit Website</button>

The onclick attribute is used to execute a JavaScript function that changes the current page location to the specified URL (in this case, “http://www.example.com“).

You can also create a link button with a <form> and <input> tags. Here’s an example:

<form action=”http://www.example.com”> <input type=”submit” value=”Visit Website”> </form>

The action attribute of the <form> tag specifies the link’s destination, and the type attribute of the <input> tag is set to “submit” to make it a button.

You can also use CSS to style the button, in order to make it look like a button, you can use the following css:

.button { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 15px 32px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; }

 

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *