Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Styling Borders with Tailwind CSS | Core Concepts and Basic Styling
Tailwind CSS for Web Development

book
Styling Borders with Tailwind CSS

Tailwind CSS provides utilities for controlling the width, style, and radius of borders.

Border Width

Use the border- prefix followed by the width value.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Basic Styling - Borders - Example 1</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="border-2 border-gray-500 p-4">2px Border</div>
<div class="border-4 border-gray-500 p-4">4px Border</div>
</body>
</html>

Border Style

Use the border- prefix for default solid borders. For other styles like dashed or dotted, use the border-dashed or border-dotted classes.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Basic Styling - Borders - Example 2</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="border-2 border-dashed border-gray-500 p-4">Dashed Border</div>
<div class="border-2 border-dotted border-gray-500 p-4">Dotted Border</div>
</body>
</html>

Border Radius

Use the rounded- prefix followed by the size value to control the border radius.

html

index.html

copy
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Basic Styling - Borders - Example 3</title>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<body>
<div class="rounded-sm bg-gray-100 p-4">Small Border Radius</div>
<div class="rounded-md bg-gray-300 p-4">Medium Border Radius</div>
<div class="rounded-lg bg-gray-500 p-4">Large Border Radius</div>
<div class="rounded-full bg-gray-700 p-4">Full Border Radius</div>
</body>
</html>

Note

If you’re looking for specific design options for border radius, border style, or border width, you can refer to the Tailwind documentation below.

question mark

How do you apply a border radius to an element in Tailwind CSS?

Select the correct answer

Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 4

Ask AI

expand
ChatGPT

Ask anything or try one of the suggested questions to begin our chat

We use cookies to make your experience better!
some-alt