How to align button to right in bootstrap?

Hi Friends 👋,

Welcome To aGuideHub! ❤️

In this article, I will show to align button to right in bootstrep with step by step guide.

Here, we will use .text-right class to make a button in right.

You can simply use the class .text-right on the containing element to right align your Bootstrap buttons within a block box or grid column. It will work in both Bootstrap 3 and 4 versions.

Example:

Let’s look at the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Right Align Bootstrap Buttons</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
    <style>
      .bs-example{
        margin: 20px;
      }
  </style>
  </head>
  <body>
  <div class="bs-example">
      <div class="container">
          <div class="row">
              <div class="col-md-12 bg-light text-right">
                  <button type="button" class="btn btn-success">Cancel</button>
                  <button type="button" class="btn btn-danger ml-2">Save</button>
              </div>
          </div>
      </div>
  </div>
  </body>
  </html

Check the output of the above code example.

Bootstrap, Align, Button, Right

If you’re using the Bootstrap 3 version please replace the class float-right with pull-right class.

All the best 👍