Table of contents
1.
Introduction
2.
Bootstrap Panels
3.
How to Create Bootstrap Panels
3.1.
Basic Panel
3.1.1.
Example
3.1.2.
Explanation of the Code
3.1.3.
Output
3.2.
Panel with Heading and Footer
3.2.1.
Example
3.2.2.
Explanation of the Code
3.2.3.
Output
3.3.
Panel Group with Contextual State Classes
3.3.1.
Example
3.3.2.
Explanation of the Code
3.3.3.
Output
3.4.
Panel with Tables
3.4.1.
Example
3.4.2.
Explanation of the Code
3.4.3.
Output
3.5.
Panels with List Groups
3.5.1.
Example
3.5.2.
Explanation of the Code
3.5.3.
Output
4.
Bootstrap Wells
5.
How to Create Bootstrap Wells
5.1.
Simple Well
5.1.1.
Example
5.1.2.
Explanation of the Code
5.1.3.
Output
5.2.
Wells of Different Sizes
5.2.1.
Example
5.2.2.
Explanation of the Code
5.2.3.
Output
5.3.
Wells with Custom Backgrounds
5.3.1.
Example
5.3.2.
Explanation of the code
5.3.3.
Output
6.
Frequently Asked Questions
6.1.
What is Bootstrap?
6.2.
What is a panel in Bootstrap?
6.3.
What is a well in Bootstrap?
6.4.
How do I change the background colour of a well?
6.5.
Do bootstrap 4 support panels and wells?
7.
Conclusion
Last Updated: Mar 27, 2024

Bootstrap - Panels and Wells

Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Hey, ninja! In this article, we will talk about bootstrap panels and wells. In bootstrap, panels are used to place DOM(Document Object Model) components in a bordered box or a <div> container with padding around their content. The wells in Bootstrap cause the content to appear sunken or inset when placed inside a box.

bootstrap panels and wells

You can use bootstrap panels and wells to attract the reader's attention to the specific content of your website. They provide padding and background colour to the container or box.
Let us begin by learning about the bootstrap panels and wells in greater detail.

Bootstrap Panels

Bootstrap panels are a feature of the Bootstrap framework that allows developers to create a box-like container for content on a web page. These panels can be used to group and organize content in a visually appealing and consistent manner. They can be customized with different colours, borders, and padding to match the overall design of a website. Bootstrap panels can include a heading, footer, and other elements such as buttons or forms. They are typically created using HTMLCSS, and JavaScript.

How to Create Bootstrap Panels

Bootstrap panels can be created by adding the .panel class to any container or block element along with the .panel-default class. The .panel-body class is used to give a panel a body. The content in the panel usually has a heading, body, and footer parts. 

Here is an example of how to create a basic Bootstrap panel using HTML:

<div class="panel panel-default">
    <div class="panel-heading">Panel Heading</div>
    <div class="panel-body"> Panel content goes here... </div>
</div>


In this example, the outer div element has a class "panel" and "panel-default", which Bootstrap provides to create the basic panel structure. The inner div element with the class "panel-heading" is used to create the panel heading, and the innermost div element with the class "panel-body" is used to create the panel body, where the content goes.

You can also use different classes, such as "panel-primary" or "panel-success," to change the panel's colour.

Additionally, you can also add a footer to the panel by adding a div element with a class "panel-footer" within the outer div.

<div class="panel panel-default">
    <div class="panel-heading">Panel Heading</div>
    <div class="panel-body"> Panel content goes here... </div>
    <div class="panel-footer">Panel Footer</div>
</div>


You also need to include Bootstrap's CSS and JS files in your HTML file to make it work.
 

Let’s look at a working example of different types of bootstrap panels that you can create.

Basic Panel

Following is an example of a simple panel.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Bootstrap Panel 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="panel panel-default">
                <div class="panel-body">Simple Panel</div>
            </div>
        </div>
    </body>
</html>


Explanation of the Code

The page contains a container element with a panel element inside, which has a ".panel-default" class to style it as a default Bootstrap panel. The panel also has a ".panel-body" element with the text "Simple Panel".


Output

simple panel

Panel with Heading and Footer

Following is an example of a panel containing a header and a footer.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Panel 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="panel panel-default">
                <div class="panel-heading">I am the heading</div>
                <div class="panel-body">I am the body</div>
                <div class="panel-footer">I am the footer</div>
            </div>
        </div>
    </body>
</html>


Explanation of the Code

The page contains a container element with a panel element inside, which has a ".panel-default" class to style it as a default Bootstrap panel. The panel has three parts: a ".panel-heading" element with the text "I am the heading," a ".panel-body" element with the text "I am the body," and a ".panel-footer" element with the text "I am the footer."


Output

panel containing header and footer

Panel Group with Contextual State Classes

Following is an example of a panel containing state classes.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Panel 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-heading">Use of panel-default class</div>
                    <div class="panel-body">Hello Ninja</div>
                </div>
                <div class="panel panel-primary">
                    <div class="panel-heading">Using panel-primary class</div>
                    <div class="panel-body">Hello Ninja!</div>
                </div>
                <div class="panel panel-info">
                    <div class="panel-heading">Using panel-info class</div>
                    <div class="panel-body">bonjour ninja</div>
                </div>
                <div class="panel panel-warning">
                    <div class="panel-heading">Using panel-warning class</div>
                    <div class="panel-body">hola ninjas</div>
                </div>
                <div class="panel panel-danger">
                    <div class="panel-heading">Using panel-danger class</div>
                    <div class="panel-body">안녕 닌자</div>
                </div>
            </div>
        </div>
    </body>
</html>


Explanation of the Code

This code creates a container with a ".panel-group" class and multiple panels with various classes such as ".panel-default", ".panel-primary", ".panel-info", ".panel-warning", and ".panel-danger". Each panel consists of a heading and a body. The different classes determine the visual styling of each panel, such as the background colour and text color. 

  • ".panel-default" sets the default styling for a panel with a neutral background.
     
  • ".panel-primary" sets the styling for a panel with a blue background.
     
  • ".panel-info" sets the styling for a panel with a light blue background.
     
  • ".panel-warning" sets the styling for a panel with a yellow background.
     
  • ".panel-danger" sets the styling for a panel with a red background.


Output

panels with contextual state classes

Panel with Tables

Following is an example of a panel containing tables.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Panel 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h2>Coding Ninjas</h2>
                    </div>
                    <div class="panel-body">
                        <b>This is a panel with a table. </b>
                        <p>
                        <table class="table">
                            <tr>
                                <th>Name</th>
                                <th>Height</th>
                            </tr>
                            <tr>
                                <td>A</td>
                                <td>168 cm</td>
                            </tr>
                            <tr>
                                <td>B</td>
                                <td>154 cm</td>
                            </tr>
                        </table>
                    </div>
                </div>
            </div>
    </body>
</html>


Explanation of the Code

This HTML code creates a web page with a Bootstrap panel group. It includes a container element with a ".panel-group" class and a panel element inside. The panel element has a ".panel-default" class to style it as a default Bootstrap panel. The panel has two parts: a "panel-heading" element with the heading "Coding Ninjas" and a "panel-body" element with a table. The table is created using the ".table" class inside the panel. The example table has two columns with headers "Name" and "Height" and two rows of data with names and heights. 


Output

panel with table

Panels with List Groups

Following is an example of a panel containing list groups.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Panel 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="panel-group">
                <div class="panel panel-primary">
                    <div class="panel-heading">
                        <h2>Coding Ninjas</h2>
                    </div>
                    <div class="panel-body">
                        <b>This is a panel with a list group. </b>
                        <p>
                        <ul class="list-group">
                            <li class="list-group-item" style="background-color: orange;">
                                <b>List of colours</b>
                            </li>
                            <li class="list-group-item" style="background-color: rgb(173, 228, 255);">Blue</li>
                            <li class="list-group-item" style="background-color: rgb(255, 177, 241);">Pink</li>
                            <li class="list-group-item" style="background-color: rgb(255, 120, 120);">Red</li>
                        </ul>
                    </div>
                </div>
            </div>
    </body>
</html>


Explanation of the Code

This HTML code creates a container element and a class ".panel-group" inside it. The "panel-group" groups a set of panels together in a single component. The body of the panel contains an unordered list with the class ".list-group". The list-group class is a Bootstrap class used to create a list of items with a specific style. The list items are styled with different background colors using the "style" attribute and the "background-color" property. The panel has a heading with the title "Coding Ninjas," followed by a list-group containing a list of colours. The list items are styled with different background colors and texts ("Blue," "Pink," and "Red").
 

Output

panels with list groups

Let us now talk about bootstrap wells.

Bootstrap Wells

Bootstrap wells serve as containers to hold content on a web page and add visual interest to it. They are used to highlight specific content, group related elements together, and create a visually appealing layout. It creates a sunken or inset effect on a web page with a grey background to draw readers' attention to specific content on a web page. Bootstrap wells also help to add padding and a rounded border around the content they hold. Additionally, they are responsive to different screen sizes, ensuring a consistent look and feel across devices. 

It helps to give the content inside the box depth and separation from the rest of the page. The well class is typically used to group related content and make it stand out from the surrounding content. It can be applied to any HTML element but is most commonly applied to the <div> element.

The bootstrap wells are available in three sizes: normal, small, and large. The size of the well can be changed by using classes like .well-sm for small, .well for normal, and .well-lg for large. These affect the padding and modify the size of a well. You can also change the background of wells by adding the background property to the CSS.

How to Create Bootstrap Wells

To create a "well" in Bootstrap, you can use the class "well" within a div element. 

Here is an example:

<div class="well">
    <p>This is some text inside the well.</p>
</div>


You can also use the ".well-lg" and ".well-sm" classes to create larger or smaller wells, respectively:

Here is an example:

<div class="well well-lg">
    <p>This is a large well.</p>
</div>
<div class="well well-sm">
    <p>This is a small well.</p>
</div>


You can adjust the padding and margin around the well by applying CSS styles to the "well" class.

Let us look at some working examples of bootstrap wells to understand them better.

Simple Well

The following is an example of a simple well.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Well 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="well">This is a Simple Well</div>
        </div>
    </body>
</html>


Explanation of the Code

This code creates a "container" div and a basic well using the ".well" class of bootstrap inside it. The text "This is a Simple Well" is displayed in the well.
 

Output

simple well

Wells of Different Sizes

Following is an example showing wells of different sizes.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Well 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="well well-sm">Well of the smallest size</div>
            <div class="well">Well of normal size</div>
            <div class="well well-lg">Well of the largest size</div>
        </div>
    </body>
</html>


Explanation of the Code

This code creates wells of three different sizes. There is a container div with three nested well divs. Three classes, ".well-sm", ".well",  and ".well-lg", are used for this purpose. These classes are used in Bootstrap to set the size of the wells, with "well-sm" being the smallest, "well" being the default size, and "well-lg" being the largest size.
 

Output

wells of different sizes

Wells with Custom Backgrounds

Following is an example of bootstrap wells that we customized using CSS.

Example

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Well 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/3.4.1/css/bootstrap.min.css">
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
    </head>
    <body>
        <div class="container">
            <div class="well" style="background-color: rgb(239, 153, 88);">Well with custom background-color</div>
            <div class="well" style="background-color: rgb(79, 205, 239); border-color: black;">Well with custom background-color and border</div>
        </div>
    </body>
</html>


Explanation of the code

This HTML code has a container div with two nested well divs. The first well has an inline style that sets the background color to "rgb(239, 153, 88)". The second well has an inline style that sets the background color to "rgb(79, 205, 239)" and the border color to "black." These styles will override any default styles set by the Bootstrap CSS.
 

Output

wells with custom backgrounds

Let us now answer some frequently asked questions.

Frequently Asked Questions

What is Bootstrap?

Bootstrap is a free and open-source CSS framework that aims to be a mobile-first front-end web development framework. It contains CSS and JavaScript-based interface components and design templates like forms, buttons, navbars, and many more.

What is a panel in Bootstrap?

A panel is a bordered box used to put DOM components into a container with padding around their content. 

What is a well in Bootstrap?

The Bootstrap well is a round, bordered, and padded box used to draw attention toward specific content on a webpage.

How do I change the background colour of a well?

The background colour of a well can be changed by using CSS to set the background property to a colour of your choice.

Do bootstrap 4 support panels and wells?

Bootstrap 4 doesn't support panels and wells. It introduced a new card component built with a flexbox for efficiency.

Conclusion

In this article, we learned about Bootstrap wells and panels. We learned about their uses and how to implement them. We also looked at some examples of bootstrap panels and wells.

To learn more about Bootstrap, you can refer to the following articles.

You may refer to our Guided Path on Code Studios for enhancing your skill set on DSACompetitive ProgrammingSystem Design, etc. Check out essential interview questions, practice our available mock tests, look at the interview bundle for interview preparations, and so much more!

Live masterclass