The Wayback Machine - https://web.archive.org/web/20241109144051/https://www.geeksforgeeks.org/borders-in-bootstrap-with-examples/
Open In App

Borders in bootstrap with examples

Last Updated : 03 Aug, 2023
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Borders: Borders are generally used to display an outline around a box or table cell or any other HTML element. In Bootstrap, there are different classes available to add or remove borders. The classes that are used to add borders are referred as Additive classes and those that are used to remove borders are referred as subtractive classes.

Additive Border Classes:  

  • .border: This class adds a border all around the element.
  • .border-top: This class adds a border on the top edge of the element.
  • .border-left: This class adds a border on the left edge of the element.
  • .border-right: This class adds a border on the right of the element.
  • .border-bottom: This class adds a border on the bottom of the element.

Subtractive Border Classes:  

  • .border-0: This class removes the border from all around the element if exists.
  • .border-top-0: This class removes the border from the top edge of the element if exists.
  • .border-left-0: This class removes the border from the left edge of the element if exists.
  • .border-right-0: This class removes the border from the right of the element if exists.
  • .border-bottom-0: This class removes the border from the bottom of the element if exists.

The below program uses all of the additive and subtractive classes to add and remove borders:  

html




<!-- Bootstrap Borders -->
<!DOCTYPE html>
<html>
 
<head>
    <title>Bootstrap Example</title>
 
    <!-- Link Bootstrap CSS -->
    <link rel="stylesheet"
          href=
 
    <!-- Link Bootstrap JS and JQuery -->
    <script src=
      </script>
    <script src=
      </script>
    <script src=
      </script>
    <style>
        /* CSS for Square boxes */
        span {
            display: inline-block;
            width: 70px;
            height: 70px;
            margin: 6px;
            background-color: #DCDCDC;
        }
    </style>
</head>
 
<body>
 
    <!-- Additive border classes -->
    <!-- Note: border-dark class is used to add
                black color to border -->
    <div class="container">
        <h2>Additive Border Classes</h2>
        <span class="border border-dark"></span>
        <span class="border-top border-dark"></span>
        <span class="border-right border-dark"></span>
        <span class="border-bottom border-dark"></span>
        <span class="border-left border-dark"></span>
    </div>
 
    <!-- Subtractive border classes -->
    <!-- Note: border-dark class is used to add
                black color to border -->
    <div class="container">
        <h2>Subtractive Border Classes</h2>
        <span class="border border-dark"></span>
        <span class="border border-0 border-dark"></span>
        <span class="border border-top-0 border-dark"></span>
        <span class="border border-right-0 border-dark"></span>
        <span class="border border-bottom-0 border-dark"></span>
        <span class="border border-left-0 border-dark"></span>
    </div>
 
</body>
 
</html>


Output: 

Color of Borders: Any color can be added to the border by using the following border-color classes that are available in Bootstrap. If you want any other customized color, then you can set it manually using the CSS attribute.
 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>Bootstrap Example</title>
 
    <!-- Link Bootstrap CSS -->
    <link rel="stylesheet"
          href=
 
    <!-- Link Bootstrap JS and JQuery -->
    <script src=
      </script>
    <script src=
      </script>
    <script src=
      </script>
 
    <style>
        /* CSS style for Boxes */
        span {
            display: inline-block;
            width: 70px;
            height: 70px;
            margin: 6px;
            background-color: #DCDCDC;
        }
    </style>
</head>
 
<body>
    <div class="container">
        <h2>Borders</h2>
 
        <p>Color Border:</p>
 
        <span class="border border-primary"></span>
        <span class="border border-secondary"></span>
        <span class="border border-success"></span>
        <span class="border border-danger"></span>
        <span class="border border-warning"></span>
        <span class="border border-info"></span>
        <span class="border border-light"></span>
        <span class="border border-dark"></span>
    </div>
</body>
 
</html>


Output: 

Radius of Borders: Border radius is used to make the corner of the border curved. The more the radius, the more curved and round it will be. 
In Bootstrap, the following classes as used in the code are used to implement radius at particular corners. 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>Bootstrap Example</title>
 
    <!-- Link Bootstrap CSS -->
    <link rel="stylesheet"
          href=
 
    <!-- Link Bootstrap JS and JQuery -->
    <script src=
      </script>
    <script src=
      </script>
    <script src=
      </script>
 
    <style>
        /* CSS Style for Boxes */
        span {
            display: inline-block;
            width: 70px;
            height: 70px;
            margin: 6px;
            background-color: #DCDCDC;
        }
    </style>
</head>
 
<body>
    <div class="container">
        <h2>Border Radius</h2>
        <!-- Below classes are used to add radius
                 to the borders -->
        <span class="rounded"></span>
        <span class="rounded-top"></span>
        <span class="rounded-right"></span>
        <span class="rounded-bottom"></span>
        <span class="rounded-left"></span>
        <span class="rounded-circle"></span>
        <span class="rounded-0"></span>
    </div>
</body>
 
</html>


Output: 

Supported Browser:

  • Google Chrome
  • Firefox
  • Opera
  • Safari


Previous Article
Next Article

Similar Reads

Bootstrap 5 Borders Sizes
Bootstrap 5 Border utility is used to set the style of the border element. The border styles can be of border-color, border-width, border-radius, etc. The Border Sizes are used to set the border-radius rounded corners larger or smaller. The range of border sizes varies from 0 to 3, where 0 represents smaller-size rounded corners and 3 represents la
2 min read
Bootstrap 5 Table borders
Bootstrap 5 Table borders classes are used to set or unset the border of the table. With bootstrap 5 table borders are easy to customize with border or no border. Bordered tables: This is used to set the border on each side of the table.Tables without borders: This is used to make the table borderless all over the table like there will be no row an
2 min read
Bootstrap 5 Borders Subtractive
Bootstrap5 Borders Subtractive is used to remove borders from the box by defining which side the border is to be removed or we can remove the border from all sides at once. Bootstrap 5 Borders Subtractive Classes: border-0: This class is used to remove borders from all around the elementborder-top-0: This class is used to remove the border from the
3 min read
Bootstrap 5 Borders Additive
Bootstrap5 Borders Additive classes are mainly used to display an outline around a box and it provides style, color, and radius of an element border on the side we want. For eg: if we want the border only on the top of the box we can have it by using the border-top additive class. Bootstrap 5 Borders Additive classes: border: This class is used to
2 min read
Bootstrap 5 Tables without borders
Bootstrap5 Tables without borders is used to create a table in borderless form. It is mostly used when we do not want to show the separation in the table content. Tables without Borders Class: table-borderless: This class is used to create borderless tables Syntax: <table class="table table-borderless"> ... </table> Example 1: In this e
2 min read
Bootstrap 5 Borders
Bootstrap 5 Borders offer predefined border styles to elements. Classes like .border, .border-0, .border-top, .border-bottom, .border-left, and .border-right provide easy customization for borders, including color, width, and radius, enhancing UI design. iframe { width: 100%; height: 450px;} @media (max-width: 1145px) {.article--viewer .a-wrapper .
2 min read
How to remove borders of a canvas-type text using Fabric.js ?
In this article, we are going to see how to remove the borders of a canvas-like text using FabricJS. The canvas means text written is movable and can be stretched according to requirement. Further, the text itself cannot be edited like a textbox.Approach: To make it possible we are going to use a JavaScript library called FabricJS. After importing
2 min read
How to set the collapsing borders model for a table ?
CSS describes the way HTML elements should be displayed. There are various CSS properties that can add magic to the basic HTML document. This article is focused on setting the collapsing borders model for the table element of HTML. HTML tables allow us to arrange our data using rows and columns. The <table> tag defines an HTML table. Each tab
3 min read
How to remove controlling borders of a canvas circle using Fabric.js ?
In this article, we are going to see how to remove the controlling borders of a canvas circle using FabricJS. The canvas means the circle is movable and can be stretched according to requirement. Further, the circle can be customized when it comes to initial stroke color, fill color, stroke width, or radius. Approach: To make it possible, we are go
2 min read
How to change Input box borders after filling the box using JavaScript ?
In this article, we will change the input border after filling in the text on the input text field. The onchange event attribute works when the value of the element changes and selects the new value from the list. Approach: Whenever the input value is changed with some value by the user, the onchange event attribute is triggered. After the event is
2 min read
Pure CSS Table with Horizontal Borders
A table is an arrangement of data in rows and columns, or possibly in a more complex structure. Tables are widely used in communication, research, and data analysis. In Pure CSS, we will add a "pure-table" class to add styles to the table. This class adds padding and borders to table elements and emphasizes the header. A table with Horizontal Borde
2 min read
Tailwind CSS Borders Complete Reference
Tailwind CSS is a highly customizable, low-level CSS framework that gives you all of the buildings blocks that you need. Tailwind CSS Border utility settings the radius, width, color, opacity, etc., of element's borders. all the properties covered as in this class form. Tailwind CSS Class Description Example Border RadiusIt is used to set the borde
2 min read
React MUI Borders
Material UI is an open-source design framework that showcases different components made in react. It is developed and maintained by Google since 2014. What is Borders API offered by Material UI? The Borders API, provided by MUI, allows us to control the border and border-radius of DOM elements that have border utilities. passed to Borders API props
3 min read
Primer CSS Responsive Borders
Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, an
3 min read
Primer CSS Borders
Primer CSS is a free and open-source CSS framework. It is built upon the systems that create the foundation of the basic style elements such as spacing, typography, and color. Created with GitHub’s design system, it is highly reusable and flexible. Primer CSS Borders is a utility class that applies borders to a div container of HTML by simply apply
3 min read
Tachyons Theming Borders
CSS border properties allow us to set the style, color, and width of the border. Tachyon is a toolkit that is used to create a responsive website. Used Classes: Border: The "ba" class is used to create a simple border.Border Top: The "bt" class is used to create a border from the top.Border Right: The "br" class is used to create a border from the
4 min read
Pure CSS applying Padding and Borders to Grid Units
Pure CSS is a free and open-source CSS framework. It is a set of instruments for developing responsive websites and online applications. This was created by Yahoo and is used to create websites that are quicker, more aesthetically beautiful, and more user-friendly. It effectively replaces Bootstrap. The responsive design was considered when creatin
3 min read
HTML Table Borders
HTML Table Borders define the visible lines around cells and the overall table. They help in creating clear distinctions between various sections of the table, making it easier to understand and show information clearly. This attribute allows you to control the border's style, color, and width, for the visual presentation of your table. Syntaxtable
5 min read
How to add Borders and Shadows to Elements in CSS ?
Apply box shadows to elements to create a 3D effect, whereas adding borders to containers or boxes can enhance the structural clarity of a layout. In this article, we will learn how to add borders and shadows to the elements in CSS. We will explore two different approaches to adding borders and shadows. Table of Content Using the border and box-sha
2 min read
Chakra UI Borders
Chakra UI is a popular React component library that simplifies the process of building user interfaces with a set of customizable and accessible components. Among those feature it also provide support for styling and layout including the management of borders. It provides various properties to customize borders. In this article, we will learn about
2 min read
How to Add Borders to Pagination in CSS ?
Add borders to Pagination is when you have many pages of content and must move between them. Making these page buttons look better can make navigating easier and more enjoyable for users. One way to do this is by adding borders to the page buttons using CSS. These are the following approaches: Table of ContentUsing Border PropertyUsing Border-Style
3 min read
Gradient borders in CSS
Creating visually appealing borders can significantly enhance the user experience on your website. One such technique is the use of gradient borders. Although CSS does not directly support gradient borders, there are two effective methods to achieve this: Try It: .custom-item { border: 1px solid gray; font-family: 'Gill Sans', 'Gill Sans MT', Calib
4 min read
CSS Borders
A CSS border is a line that surrounds an HTML element, providing a visual separation between the element and its surroundings. Borders can be styled in various ways, including adjusting their width, color, and style. The basic properties used to define borders in CSS are border-width, border-style, and border-color. Here, We covered CSS borders, in
5 min read
Include Bootstrap in AngularJS using ng-bootstrap
AngularJS can be integrated with Bootstrap CSS and Javascript and can be used to create creative forms, tables, navigation bars, etc. Steps: Make sure the Angular CLI present in your system if not then run the command in the terminal to do so. npm install -g @angular/cli Create a new project on visual studio code by running the code ng new project-
2 min read
Difference between bootstrap.css and bootstrap-theme.css
Bootstrap is an HTML, CSS and JS front-end-framework used for developing responsive and mobile-first projects on the web. It is the framework that comes up with predefined terms, thus giving you the ability to use these codes instead of having to create the codes from scratch. It is a collection of HTML, CSS and JS code that is designed to help bui
5 min read
Difference Between Bootstrap 3 and Bootstrap 4
Bootstrap: Bootstrap was developed by Mark Otto and Jacob Thorton at Twitter in August 2011. It is an open-source framework that is used to design responsive websites faster and easier. It is the most popular open-source framework that includes HTML, CSS, and JavaScript. It can create web applications with any server-side Technology like Java, PHP,
2 min read
Difference between Bootstrap 4 and Bootstrap 5
What is Bootstrap? It is an open-source framework from late 2011 that is used for designing responsive websites with a mobile-first approach faster and easier. Bootstrap is available for HTML, CSS, and JS. According to server-side languages like PHP, Node, etc. bootstrap helps to design the frontend. Bootstrap has made the work for developers easie
3 min read
Bootstrap Cheat Sheet - A Basic Guide to Bootstrap
Bootstrap is a free, open-source, potent CSS framework and toolkit used to create modern and responsive websites and web applications. It is the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites. Nowadays, websites are perfect for all browsers and all sizes of screens. What is Bootstrap Cheat Sheet?A
15+ min read
Visibility of elements in bootstrap with Examples
There are some situations where it is needed to hide some content on a webpage without affecting the layout of the page. Bootstrap uses the CSS visibility property and provide two classes visible and invisible to control the visibility of an element on a web page.These classes do not affect the layout i.e. invisible elements will still take up spac
3 min read
Vertical alignment in Bootstrap with Examples
Vertical Alignment in bootstrap changes the alignment of elements vertically with the help vertical-alignment utilities. The vertical-align utilities only affects inline(Present in one Line), inline-block(Present as blocks in one line), inline-table, and table cell(Elements in a cell of a table) elements.Various classes available in bootstrap libra
2 min read
Article Tags :
three90RightbarBannerImg