How to create full width container in bootstrap5?

Bootstrap containers are content holders that are used to align, add margins and padding to your content.  Bootstrap has three different container classes, namely: 

  • .container
  • .container-fluid
  • .container-{breakpoint}

Width of a container varies in accordance with its class. We can create a full width container in Bootstrap5 using “.container-fluid” class. It sets the container width equal to 100% in all screen sizes. This means the container spans the entire width of the viewport.

Syntax:

<div class= ".container-fluid">
  ...
</div>  

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet"
              href=
              integrity=
"sha384-r4NyP46KrjDleawBgD5tp8Y7UzmLA05oM1iAEQ17CSuDqnUK2+k9luXQOfXJCJ4I"
              crossorigin="anonymous" />
  
        <style>
            .gfg {
                background-color: green;
                color: white;
                text-align: center;
            }
        </style>
    </head>
  
    <body>
        <div class="container-fluid gfg">
            <h2>GeeksforGeeks</h2>
        </div>
    </body>
</html>

chevron_right


Output:

full-stack-img

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.