Bootstrap, the popular CSS framework, has always been a go-to for web developers seeking to create responsive and mobile-first websites. With the release of Bootstrap 5, the framework has introduced several new features and improvements, including a revamped card component. One of the standout features of Bootstrap 5 cards is their ability to display side by side, enhancing the user interface's visual appeal and organization.

In this article, we'll delve into the world of Bootstrap 5 cards and explore how to display them side by side. We'll cover the basics, dive into the code, and provide practical examples to help you master this essential skill.

Understanding Bootstrap 5 Cards
Before we jump into displaying cards side by side, let's briefly recap what Bootstrap 5 cards are and their basic usage. Cards are a flexible and extensible content container. They allow you to create self-contained units of content with a heading and body, optionally including other elements like links, buttons, and media.

In Bootstrap 5, cards are built with CSS flexbox and are fully responsive. They use the `.card` class, with various utility classes available for customization, such as `.card-title`, `.card-text`, and `.card-body`.
Basic Bootstrap 5 Card Structure

Here's a basic example of a Bootstrap 5 card:
<div class="card" style="width: 18rem;">
<img src="..." class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title">Card title</h5>
<p class="card-text">Some quick example text to build on the card title and make up the bulk of the card's content.</p>
<a href="#" class="btn btn-primary">Go somewhere</a>
</div>
</div>
This code creates a card with an image at the top, a title, some text, and a button.
Displaying Cards Side by Side with Flexbox

To display Bootstrap 5 cards side by side, we'll use the power of CSS flexbox. Flexbox is a one-dimensional layout model that allows items to be placed in a row or column, with proper alignment and distribution. In our case, we'll use it to place cards in a row.
First, wrap your cards in a container with the `.d-flex` class, which applies `display: flex;` to its children. Then, add the `.flex-wrap` class to allow the flex items to wrap as needed:
<div class="d-flex flex-wrap">
<div class="card mr-2 mb-2" style="width: 18rem;">
...
</div>
<div class="card mr-2 mb-2" style="width: 18rem;">
...
</div>
</div>
The `mr-2` and `mb-2` classes add right and bottom margins to the cards, creating space between them. Adjust these values as needed to achieve the desired layout.

Responsive Card Layouts
Bootstrap 5 cards are fully responsive, meaning they adapt to different screen sizes. By default, cards will stack on top of each other on small screens and display side by side on larger screens. However, you can customize this behavior using responsive display utilities.











For example, to display cards side by side only on medium and larger screens, you can wrap them in a container with the `.d-none d-sm-flex` classes:
<div class="d-none d-sm-flex flex-wrap">
<div class="card mr-2 mb-2" style="width: 18rem;">
...
</div>
<div class="card mr-2 mb-2" style="width: 18rem;">
...
</div>
</div>
In this case, the cards will be hidden on small screens (xs) and displayed side by side on medium (sm) and larger screens.
Equal-Width Cards
To create equal-width cards, you can use the `.col` classes from Bootstrap's grid system. Wrap each card in a `.col` element with the desired number of columns. For example, to create three equal-width cards, use `.col-md-4`:
<div class="d-flex flex-wrap">
<div class="col-md-4 mb-3">
<div class="card">
...
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card">
...
</div>
</div>
<div class="col-md-4 mb-3">
<div class="card">
...
</div>
</div>
</div>
This will create three equal-width cards that stack on top of each other on small screens and display side by side on medium and larger screens.
In conclusion, displaying Bootstrap 5 cards side by side is a powerful way to organize and present content on your website. By harnessing the power of CSS flexbox and Bootstrap's grid system, you can create responsive and engaging card layouts that adapt to various screen sizes. So go ahead, experiment with different layouts, and make your web pages shine with beautifully arranged Bootstrap 5 cards.