WEB TUTORIALS
PRACTICE EXAMPLES
HTML REFERENCES
CSS REFERENCES
PHP REFERENCES

How to Get Right Aligned Buttons in Bootstrap

Topic: Bootstrap / SassPrev|Next

Answer: Use the text-right Class

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.

Let's try out the following example to understand how it basically works:

<div class="container">
    <div class="row">
        <div class="col-md-12 bg-light text-right">
            <button type="button" class="btn btn-primary">Cancel</button>
            <button type="button" class="btn btn-warning">Save</button>
        </div>
    </div>
</div>

Let's check out one more example. Here, buttons and text are placed inside a div element side by side. To align text to the left and buttons to right we need to use the .float-right property on the button elements. Also, if the button elements are not inside a grid column (i.e., .col-*) then you also need apply the class .clearfix on the parent <div> element.

<div class="bg-light clearfix">
    <span>Click any button to proceed</span>    
    <button type="button" class="btn btn-warning float-right">Save</button>
    <button type="button" class="btn btn-primary float-right">Cancel</button>
</div>

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


Related FAQ

Here are some more FAQ related to this topic:

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties