Bootstrap Buttons
Updated Mar 29, 2019 ·
Overview
Bootstrap provides different button styles with easy-to-use classes.
See: Sample HTML File
See: Sample Website
<!-- Button trigger modal -->
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title fs-5" id="exampleModalLabel">Modal title</h1>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Links in Buttons
Use a href element
To make a Bootstrap 5 button behave like a link (example: go to another page using href), you should use an <a> tag instead of a <button> tag, but style it like a button using Bootstrap classes.
<button>doesn't supporthref;- It's meant for form actions or JavaScript.
As an example, we write Bootstrap buttons like this:
<button type="button" class="btn btn-primary btn-lg supp-sec-8-btn rounded-pill">
Send us a question
</button>
To add a link, rewrite it with an <a> tag:
<a href="your-target-link.html" class="btn btn-primary btn-lg supp-sec-8-btn rounded-pill">
Send us a question
</a>
You can also point it to a specific part of the same page:
<a href="#section-abc" class="btn btn-primary btn-lg supp-sec-8-btn rounded-pill">
Send us a question
</a>
Then somewhere else on your page, add id="section-abc" to the element:
<section id="section-abc">
<!-- Content here -->
</section>