How to make a hyperlink that works like a button?
How to make a hyperlink that works like a button?
575
29-Aug-2023
Updated on 02-Sep-2023
Aryan Kumar
02-Sep-2023To make a hyperlink that works like a button, you can wrap the hyperlink in an
<a>tag with thebuttontype attribute. Thebuttontype attribute tells the browser to render the hyperlink as a button.The following code shows how to make a hyperlink that works like a button:
HTML
In this code, the
<a>tag has thehrefattribute set to the URL of Google and thetypeattribute set tobutton. This will render the hyperlink as a button that, when clicked, will navigate to the Google website.You can also style the button using CSS. The following CSS code shows how to style the button to have a blue background and white text:
CSS
In this code, the
a.buttonselector is used to select all hyperlinks with thebuttontype attribute. Thebackground-colorproperty is set to blue, thecolorproperty is set to white, thepaddingproperty is set to 10px 20px, and theborder-radiusproperty is set to 5px.