Border width utilities let you quickly set how thick the border around an element is. This helps you make your design clear and neat.
Border width utilities in Tailwind
Start learning this pattern below
Jump into concepts and practice - no test required
border-{side?}-{width}
// Examples:
border-2 // sets border width to 2 pixels on all sides
border-t-4 // sets top border width to 4 pixels
border-l-0 // removes left border by setting width to 0{side?} is optional and can be t (top), r (right), b (bottom), l (left), or omitted for all sides.
{width} is a number representing the border thickness in pixels, like 0, 2, 4, 8.
border-2
border-t-4
border-l-0
border-b-8
This example shows four boxes with different border widths and sides using Tailwind border width utilities. Each box uses padding so the border is visible around the text.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1" /> <title>Border Width Utilities Example</title> <script src="https://cdn.tailwindcss.com"></script> </head> <body class="p-6"> <section class="max-w-md mx-auto space-y-6"> <div class="border-2 border-blue-500 border-solid p-4"> <p>This box has a 2px blue border on all sides.</p> </div> <div class="border-0 border-t-4 border-red-500 border-solid p-4"> <p>This box has a 4px red border only on the top.</p> </div> <div class="border border-green-500 border-l-0 p-4"> <p>This box has a 1px green border except no left border.</p> </div> <div class="border-0 border-b-8 border-yellow-500 border-solid p-4"> <p>This box has a thick 8px yellow border only on the bottom.</p> </div> </section> </body> </html>
Border width utilities only set the thickness. You still need to set border-style (like solid) and border-color for the border to show.
Use border-0 to remove borders completely.
Combine with responsive prefixes like md:border-4 to change border width on different screen sizes.
Border width utilities control how thick borders are on elements.
You can set border width on all sides or just one side.
Remember to set border color and style to see the border.
Practice
Solution
Step 1: Understand Tailwind border width classes
Tailwind usesborder-{size}to set border width on all sides.Step 2: Identify the correct class for 4 pixels
The classborder-4sets border width to 4 pixels on all sides.Final Answer:
border-4 -> Option BQuick Check:
border width 4px = border-4 [OK]
- Using non-existent classes like border-width-4
- Confusing border thickness with border style
- Forgetting to add border color to see the border
Solution
Step 1: Recall Tailwind side-specific border width syntax
Tailwind usesborder-{side}-{width}with short side names: t (top), r (right), b (bottom), l (left).Step 2: Match the correct class for top border 2 pixels
border-t-2correctly sets top border width to 2 pixels.Final Answer:
border-t-2 -> Option DQuick Check:
Top border 2px = border-t-2 [OK]
- Writing full words like border-top-2 (not valid)
- Mixing order like border-2-top
- Using incorrect abbreviations like border-2t
<div class="border-l-8 border-r-2 border-t border-b-0 border-black border-solid">Content</div>Solution
Step 1: Analyze each border width class
border-l-8sets left border 8px,border-r-2right border 2px,border-tdefaults to 1px,border-b-0bottom border 0px.Step 2: Confirm border color and style
border-blackandborder-solidensure border is visible with black solid lines.Final Answer:
Left: 8px, Right: 2px, Top: 1px, Bottom: 0px -> Option AQuick Check:
border-l-8, border-r-2, border-t=1, border-b-0 [OK]
- Assuming border-t means 0px
- Mixing left and right widths
- Ignoring border style or color needed to see border
<div class="border-t-3 border-b-5 border-black">Box</div> but the top border does not appear. What is the likely problem?Solution
Step 1: Check if border style is set
Tailwind border width classes only set width. Without a border style likeborder-solid, borders won't show.Step 2: Confirm border color is set
border-blacksets color, so color is not the issue here.Final Answer:
You must addborder-stylelikeborder-solidto see borders -> Option CQuick Check:
Border style missing = no visible border [OK]
- Assuming border width alone shows border
- Thinking border-t-3 is invalid (it is valid)
- Believing one border side overrides another
Solution
Step 1: Understand default and responsive classes
Useborder-b-1for 1px bottom border by default (small screens). Thenmd:border-b-4for medium screens,lg:border-b-8for large screens.Step 2: Check for correct syntax and order
border-b border-b-1 md:border-b-4 lg:border-b-8correctly usesborder-b-1(default),md:border-b-4, andlg:border-b-8. Theborder-bclass alone sets 1px but is redundant withborder-b-1.Final Answer:
border-b border-b-1 md:border-b-4 lg:border-b-8 -> Option AQuick Check:
Responsive bottom border widths set correctly [OK]
- Using sm: instead of md: for medium screens
- Missing the default border width class
- Using invalid class names like border-b-1 (valid but redundant with border-b)
