How to create block level buttons in Bootstrap ?
Last Updated :
30 Jul, 2024
In many websites, we notice that there are big block level buttons used to perform some work when the user clicks on them. This is used to trigger some functions or redirect the user to a different link. Block buttons are the responsive stack of buttons of full width. We will use the below approach to create these types of buttons.
Approach: The btn class followed by contextual classes is used to create buttons on the website. Some of the btn classes are btn-block, btn-lg, btn-primary, btn-success, btn-warning etc. btn-block are used for block level buttons and btn-success, btn-warning, and btn-primary are for the green, yellow, and blue color of the button.
Below is the procedure to implement a simple block button in Bootstrap.
Step 1: Include Bootstrap and jQuery CDN into the <head> tag before all other stylesheets to load our CSS.
<link rel=”stylesheet” href=”https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css”>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js”></script>
<script src=”https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js”></script>
<script src=”https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js”></script>
Step 2: We will add the type as button and add classes btn, btn-primary, btn-lg and btn-block. We will then write the text that will be seen on the button.
<button type="button" class="btn
btn-primary btn-lg btn-block">
Click Here
</button>
Example:
HTML
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" />
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
</script>
<script src=
"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js">
</script>
</head>
<body>
<h2 class="text-center">GeeksForGeeks</h2>
<br><br>
<div class="text-center">Block Button</div>
<br><br>
<button type="button" class="btn btn-primary
btn-lg btn-block">
Click Here
</button>
</body>
</html>
Output:
Similar Reads
How to create an outline button in Bootstrap 4 ? Before performing with outline classes of bootstrap just know about a little bit of button outline. An outline on buttons means to give an outline around the buttons. This '.btn-outline' class removes all background colors or styles from the button for giving the Effective, lighter, and highlighter
4 min read
How to create a basic button group in Bootstrap ? Button: The .btn classes are used with the <button> element to create the basic button using Bootstrap. The buttons in bootstrap are used in forms, dialogs, etc. Button Groups in Bootstrap: In Bootstrap, button groups has group of buttons together on a single line. Button group is created usin
2 min read
How to Create "Add to cart" Button in Bootstrap? Creating an "Add to Cart" button in Bootstrap is simple and helps improve the shopping experience on your website. Bootstrap has ready-made styles that make it easy to create buttons that look good and work well on all devices.Approach to creating an "Add to cart" Button in BootstrapUse a Bootstrap
2 min read
How to get circular buttons in bootstrap 4 ? It is an open source toolkit for developing with the HTML, CSS, and JS. It includes several types of buttons, styles, fonts each of them serving its own semantic purpose which is predefined, with a few extras thrown for more control. You can use Bootstrap custom button styles to create your buttons
2 min read
How to Customize Button Styles in Bootstrap ? Customizing button styles in Bootstrap involves modifying predefined classes or creating custom CSS rules. This allows alignment with brand identity, and differentiation, and ensures design consistency across projects. We can customize button styles in Bootstrap using different approaches as listed
3 min read