Open In App

How to Add Top Space Between Rows in Twitter Bootstrap ?

Twitter Bootstrap is a popular front-end development framework that provides a set of tools and features to help developers create responsive and mobile-first websites quickly and easily. One of the features offered by Bootstrap is the ability to add top space between rows. This allows developers to create better layouts and improve the overall appearance of their web pages.

Syntax: To add top space between rows in Bootstrap, you can use the “mt” class followed by a number to specify the amount of space you want to add. The syntax for adding top space is as follows:



<div class="row mt-3">
    <div class="col">Column 1</div>
    <div class="col">Column 2</div>
    ...
</div>

Approaches: There are several approaches you can use to add top space between rows in Bootstrap, including:

Example 1: This example describes adding the top space between rows using Twitter Bootstrap by implementing the “mt” class.






<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
</head>
  
<body>
    <div class="container text-center">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <h3>
            Twitter Bootstrap - add top space between rows
        </h3>
        <div class="row">
            <div class="col border bg-primary">
                Column 1
            </div>
            <div class="col border bg-danger">
                Column 2
            </div>
        </div>
        <div class="row mt-5">
            <div class="col border bg-primary">
                Column 1
            </div>
            <div class="col border bg-danger">
                Column 2
            </div>
        </div>
    </div>
  
</body>
  
</html>

Output:

 

Example 2: This is another example that describes adding the top space between rows using custom CSS.




<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
    <style>
        .custom-spacing {
            margin-top: 50px;
        }
    </style>
</head>
  
<body>
    <div class="container text-center">
        <h1 class="text-success">
            GeeksforGeeks
        </h1>
        <h3>
            Twitter Bootstrap - add top space between rows
        </h3>
  
        <div class="container">
            <div class="row">
                <div class="col border bg-success">
                    Column 1
                </div>
                <div class="col border bg-warning">
                    Column 2
                </div>
            </div>
            <div class="row custom-spacing">
                <div class="col border bg-success">
                    Column 1
                </div>
                <div class="col border bg-warning">
                    Column 2
                </div>
            </div>
        </div>
    </div>
</body>
  
</html>

Output:

 


Article Tags :