0PricingLogin
Tailwind CSS Academy · Lesson

Border Width and Color

Add borders with border-* width utilities, set their color with border-{color}-{shade}, and control individual sides.

Adding Borders With Tailwind

Borders visually separate elements, define form fields, and add structure to card layouts. Tailwind provides the border family of utilities to control width, color, style, and individual sides — all without writing custom CSS. The base border class applies a 1px solid border in the current border color, giving you a clean starting point for any bordered component.

<!-- Simple bordered card -->
<div class="border border-gray-200 rounded-lg p-4 max-w-sm">
  <h3 class="font-semibold">Card Title</h3>
  <p class="text-gray-600 mt-2">Card content with a simple border.</p>
</div>

Border Width Utilities

Tailwind's border width utilities control thickness: border (1px), border-2 (2px), border-4 (4px), and border-8 (8px). The plain border class without a number sets the width to 1px. You can also use border-0 to explicitly remove a border — useful when inheriting a border from a base style that you want to suppress.

<!-- Different border widths -->
<div class="space-y-3">
  <div class="border p-3 rounded">border (1px)</div>
  <div class="border-2 p-3 rounded">border-2 (2px)</div>
  <div class="border-4 p-3 rounded">border-4 (4px)</div>
  <div class="border-8 p-3 rounded">border-8 (8px)</div>
</div>

All lessons in this course

  1. Border Width and Color
  2. Border Radius and Rounded Corners
  3. Box Shadows
  4. Outline and Ring Utilities
← Back to Tailwind CSS Academy