← Back to Bootstrap Course | Chapter 4: Colors & Spacing | Lesson 3 of 7

Border colors

Border utilities add or remove borders and set their colour, width and roundness.

In this page:

  1. Border colors
Syntax
markup
<div class="border border-primary">all sides</div>
<div class="border-top border-danger">top only</div>

Border colors

.border adds a border on all sides, .border-top and friends target sides, and .border-0 removes them. Colour with .border-primary, width with .border-1 to .border-5, and radius with .rounded, .rounded-circle and .rounded-pill.

Subtle border colours end with -subtle.

Note: rounded-circle needs equal width and height to make a true circle.

Example: Border colors

markup
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body class="p-3">
<div class="container">
  <div class="border border-primary border-3 p-3 mb-2">border-primary border-3</div>
  <div class="border-top border-danger p-3 mb-2">only a top border</div>
  <div class="border rounded-pill p-2 mb-2 text-center">rounded-pill</div>
  <div class="border border-success-subtle rounded-circle d-inline-block" style="width:4rem;height:4rem"></div>
</div>
</body>
</html>
Live Example
Related Topics
Common Mistakes
  1. Adding border colour without a border
  2. Forgetting border width classes
  3. Using custom CSS for radius
Chapter Summary
  • border adds borders
  • border-{color} sets the colour
  • border-1 to 5 set width
  • rounded-* sets radius
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.