How to col align right in Bootstrap 5 ?
Last Updated :
28 Apr, 2025
Bootstrap 5 provides a series of classes that can be used to apply various styling to the tables such as changing the heading appearance, making the rows striped, adding or removing borders, making rows hoverable, etc. In this article, we will learn how we can right align the content in Col. We will create a row with 2 cols. One col on the left with its contents, and the second col with its contents aligned right.
Using Bootstrap 5 text-end
In Bootstrap 5 the text-right is now text-end. We will use this class to align the content on the right side of the col. The utility class text-center centers the text, class mt-1 gives the margin-top, and class text-success colors the text green. The class row defines the row, class col defines the columns, class bg-success colors the background color with green, class bg-primary gives the background color blue, and the class text-end aligns the text to the end on all screen sizes.
Example: This example describes aligning the col to the right using the text-end utility class in Bootstrap 5.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container
text-center">
<div class="mt-1">
<h2 class="text-success">
GeeksforGeeks
</h2>
<h2>
How to col align right
in Bootstrap 5?
</h2>
</div>
<div class="row">
<div class="col bg-success
text-light">
Left Aligned Content
</div>
<div class="col text-end
bg-warning">
Right aligned
</div>
</div>
</div>
</body>
</html>
Output:

Using Bootstrap 5 col float-end
The Bootstrap utility class float-right is now float-end. We will use this to right align the content in the col. The float-end class floats the element to the right side on all the screen sizes. The utility class text-center centers the text, class mt-1 gives the margin-top, and class text-success colors the text to the green color. The class row defines the row, class col defines the columns, class bg-success colors the background color with green, class bg-primary gives the background color blue, and the class text-end aligns the text to the end on all screen sizes.
Example: This example describes the float-end utility class col aligned right in Bootstrap 5.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container text-center ">
<div class="mt-1">
<h2 class="text-success">
GeeksforGeeks
</h2>
<h2>
How to col align right in Bootstrap 5?
</h2>
</div>
<div class="row">
<div class="col bg-success
text-light ">
Left Aligned Content
</div>
<div class="col bg-primary
text-light
float-end text-end">
Right aligned
</div>
</div>
</div>
</body>
</html>
Output:

Using Bootstrap 5 col ms-auto
The Bootstrap utility class ms-auto is used to right-align the text. In bootstrap 5, ml-auto is now ms-auto. The utility class text-center to center the text, mt-1 gives the margin-top, text-success color the text green color, row defines the row, col defines the columns, bg-success colors the background color with green, bg-primary gives the background color blue, and text-end aligned the text to the end on all screen sizes.
Example: This example describes the ms-auto utility class col align right in Bootstrap 5.
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<link href=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
rel="stylesheet">
<script src=
"https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js">
</script>
</head>
<body>
<div class="container text-center ">
<div class="mt-1">
<h2 class="text-success">
GeeksforGeeks
</h2>
<h2>
How to col align right in Bootstrap 5?
</h2>
</div>
<div class="row">
<div class="col
bg-success
text-light ">
Left Aligned Content
</div>
<div class="col bg-primary
text-light ms-auto
text-end">
Right aligned
</div>
</div>
</div>
</body>
</html>
Output:

Similar Reads
How to Align Text in Bootstrap Column ? In Bootstrap Framework, we can align the text within the columns using various utility classes. To align text within a Bootstrap column, use the built-in utility classes such as text-start, text-center, and text-end for the left, center, and right alignment, respectively. Simply apply the desired cl
3 min read
How to align images in Bootstrap 4 ? We know that adding images to a website makes it more attractive and presentable. Sometimes, we need to align the images either at the right or to the left. Most of the time, we place an image at the center. With traditional CSS, we had to write a bunch of code to accomplish this specific task. Boot
4 min read
How to align two navbars in bootstrap? Aligning two navbars in Bootstrap involves utilizing its built-in navbar classes and custom CSS styles to create and position navigation bars on a web page. Bootstrap provides predefined classes for navbars that facilitate easy creation and customization. ApproachThe HTML document imports Bootstrap
2 min read
How to Left & Right Align Text within a Div in Bootstrap ? Bootstrap is used to customize the appearance and layout of web applications. To left and right align text within a <div> in Bootstrap, we can use utility classes such as text-start and text-end, combined with the grid system for responsive design. Below are the approaches to let and right ali
2 min read
How to set the button alignment in Bootstrap ? Bootstrap buttons are no different from any other DOM elements of an HTML document. Aligning them is more likely the same as aligning paragraphs, divs and sections. Here are some of the scenarios that one can encounter.Here we are using some common methods:Table of ContentButtons in container classB
4 min read