Display Property in Bootstrap with Examples

24 Jan, 2019
The display property in Bootstrap is used to set an element’s display property. The utilities such as block, inline etc are to set the element’s display property.
The display property classes of bootstrap help to directly set the CSS display property for an element.
The available classes are:
.d-block: This class when used with an element, sets it display property to block. Using this class with an element is equivalent to the below styling:style = "display: block;"

style = "display: block;"

.d-inline: This class when used with an element, sets it display property to inline. Using this class with an element is equivalent to the below styling:style = "display: inline;"

style = "display: inline;"

.d-inline-block: This class when used with an element, sets it display property to inline-block. Using this class with an element is equivalent to the below styling:style = "display: inline-block;"

style = "display: inline-block;"

Syntax:
<div class=”d-inline”> Inline </div> // for inline display
<div class=”d-block”> Block </div> // for block display
<div class=”d-inline-block”> Inline Block </div> // for inline-block display
Below examples illustrate the use of the display properties classes of bootstrap:
Example 1:
<!DOCTYPE html><html>       <head>    <style>        div{ font-size: 30px; }    </style>           <!-- Include Bootstrap CSS and JS -->    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/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/3.3.7/js/bootstrap.min.js"></script>           <title>Webpage</title></head>   <body>    <div class="d-block bg-primary">        GeeksforGeeks    </div>            <div class="d-block bg-primary">        GeeksforGeeks    </div>  </body></html>
Output:
Example 2:
<!DOCTYPE html><html>       <head>    <style>        div{ font-size: 30px; }    </style>           <!-- Add Bootstrap CSS and JS -->    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">        <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>       <title>Webpage</title></head>   <body>    <div class="d-inline bg-success">        GeeksforGeeks    </div>           <div class="d-inline bg-success">        GeeksforGeeks    </div> </body></html>
Output:
Example 3:
<!DOCTYPE html><html>       <head>    <style>        body{ font-size: 75px; }    </style>           <!-- Add Bootstrap CSS and JS -->    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">         <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>            <title>Webpage</title></head>   <body>    <div class="d-inline-block bg-warning">          GeeksforGeeks    </div>          <div class="d-inline-block bg-warning">          GeeksforGeeks    </div></body></html>
Output:
Picked
Bootstrap
CSS
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
How to change navigation bar color in Bootstrap ?
Form validation using jQuery
How to pass data into a bootstrap modal?
How to align navbar items to the right in Bootstrap 4 ?
How to Show Images on Click using HTML ?
How to update Node.js and NPM to next version ?
Top 10 Projects For Beginners To Practice HTML and CSS Skills
How to insert spaces/tabs in text using HTML/CSS?
How to create footer to stay at the bottom of a Web page?
CSS to put icon inside an input element in a form