Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

bootstrap button href does not work

Tags:

href

button

Can someone please explain why my link does not work?

<!-- Optional theme  this one is ok -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
<button type="button" class="btn btn-primary" href="#">Get your Free Quote now!</button>
like image 330
cboy Avatar asked Mar 05 '16 15:03

cboy


People also ask

Does href work on button?

HTML buttons cannot have href attribute if they are created using button <button> </button> HTML tags. However, you can use href attribute if you create the buttons using link <a> </a> HTML tags.

How do I add a link to a Bootstrap button?

Use the . btn-link class in Bootstrap to create a button look like a link.

How do I link a button to another page in HTML?

In HTML, a button link to another page can be by using the <a> tag, <input> tag, and the <form> tag. A link on a button is get by href=”” attribute of <a> tag. The “type=button” and “onclick=link” attributes are used to create a link on the button.


2 Answers

The proper way to do it is use but with class of buttons.

<a href="https://www.google.com" class="btn btn-primary">Get your Free Quote now!</a>

Fiddle Example:

https://jsfiddle.net/aq9Laaew/159899/

like image 51
Sanket9394 Avatar answered Oct 26 '22 13:10

Sanket9394


You can do the following: It works.

<a href="#"><button type="button" class="btn btn-primary">Get your Free Quote now!</button></a>

The design style of the button remains unchanged.

like image 33
Kallol Acharya Avatar answered Oct 26 '22 15:10

Kallol Acharya