Skip to content
Related Articles

Related Articles

How to align button to right side of text box in Bootstrap?

View Discussion
Improve Article
Save Article
  • Difficulty Level : Medium
  • Last Updated : 18 Aug, 2021

Bootstrap allows us to align elements by using the utility class float. As we want to align the button to the right side of the text box, we have to use the float-right class. 

<button class="btn btn-success btn-lg float-right" type="submit">Submit</button>



<!DOCTYPE html>
    <title>Bootstrap Button Alignment</title>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1">
    <link rel="stylesheet"
    <script src=
    <script src=
    <script src=
    <div class="container">
        <h1 style="text-align:center;color:green;">
            <div class="form-group">
                <label for="">Enter Your Name:</label>
                <input class="form-control"
                       placeholder="Input Your Name Here">
            <div class="form-group">
                <button class="btn btn-success btn-lg float-right"


Note: Although by default, elements like buttons, are left-aligned still we can use float-left class to mention it specifically. We can also use the class float-none to remove any hierarchical floating. 
It is important to note that we are using Bootstrap 4 here, in Bootstrap 3 or Bootstrap 2 we can use the helper classes like pull-left, pull-right to align the elements to the left or right accordingly.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!