Float an element to the right with Bootstrap 4


If you want to float an element on the right, you need to use the float-right class.

Set it on the right −

<div class="float-right">
  The text is on right!
</div>

Let us see an example to float element on the right −

Example

Live Demo

<!DOCTYPE html>
<html lang="en">
<head>
  <title>Bootstrap Example</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
</head>

<body>

  <div class="container">
    <h2>Guidelines</h2>
    <div class="clearfix">
      <div class="float-right">The text is on right!</div><br>
      <div class="float-left">This is demo text.</div><br>
    </div>
  </div>

</body>
</html>

Updated on: 18-Jun-2020

107 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements