Bootstrap ยท Chapter 37 of 43

Bootstrap Borders

Border utility classes let you add or remove borders and control their color and roundness without custom CSS. The base .border class adds a thin gray border on all sides.

You can target individual sides with .border-top, .border-end, etc., remove borders with .border-0, and add rounded corners with .rounded or .rounded-circle.

Syntax
<div class="border border-primary rounded p-3">...</div>

Adding and removing borders

.border adds a border to all sides. .border-top, .border-bottom, .border-start, and .border-end add a border to just one side. .border-0 removes all borders.

Border color and radius

Add .border-{color} like .border-danger to color the border. Add .rounded, .rounded-top, or .rounded-circle to control corner roundness.

Example 1 (html)
<div class="border border-success rounded p-3 mb-2">Bordered box</div>
<div class="border-0 shadow-sm p-3">No border, just a shadow</div>
Output
A rounded green-bordered box, followed by a borderless box with a soft shadow

border-success colors the border green, rounded softens the corners, and border-0 removes the border entirely on the second box.

Example 2 (html)
<img src="https://via.placeholder.com/100" class="rounded-circle border border-3 border-dark" alt="Avatar">
Output
A circular image with a thick dark border around it

border-3 increases the border thickness, and rounded-circle combined with it creates a framed avatar look.

Key points

  • .border adds a border on all sides; .border-0 removes it.
  • Side-specific classes like .border-top add a border to one side only.
  • .border-{color} sets the border's color.
  • .rounded and .rounded-circle control corner roundness.
๐Ÿ’ก Note: Border width classes like .border-2 or .border-3 (from 1 to 5) let you increase the default border thickness.

๐Ÿ“ Quick Quiz

1. Which class adds a border on all sides?

2. Which class removes all borders?

3. Which class makes an image's corners fully round?