Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Border color and style
📖 Scenario: You are creating a simple card component for a website. The card should have a visible border with a specific color and style to make it stand out.
🎯 Goal: Build a card using Tailwind CSS that has a red border with a dashed style.
📋 What You'll Learn
Create a div element with the class card.
Add a red border to the card using Tailwind CSS classes.
Make the border style dashed using Tailwind CSS classes.
Ensure the card has some padding and margin for spacing.
💡 Why This Matters
🌍 Real World
Borders help separate content visually on websites. Using colors and styles makes elements stand out or look subtle depending on design needs.
💼 Career
Knowing how to style borders with Tailwind CSS is useful for front-end developers to create visually appealing and accessible user interfaces quickly.
Progress0 / 4 steps
1
Create the card container
Create a div element with the class card inside the body tag.
Tailwind
Hint
Use a div tag and add class="card" inside the body.
2
Add red border color
Add the Tailwind CSS class border-red-500 to the div with class card to set the border color to red.
Tailwind
Hint
Add border-red-500 to the existing class attribute.
3
Add dashed border style
Add the Tailwind CSS class border-dashed to the div with class card border-red-500 to make the border dashed.
Tailwind
Hint
Add border-dashed to the existing class attribute.
4
Add padding and margin for spacing
Add the Tailwind CSS classes p-4 for padding and m-4 for margin to the div with class card border-red-500 border-dashed.
Tailwind
Hint
Add p-4 and m-4 to the existing class attribute for spacing.
Practice
(1/5)
1. Which Tailwind class sets the border color to red?
easy
A. border-red-500
B. border-color-red
C. red-border
D. border-red
Solution
Step 1: Understand Tailwind color naming
Tailwind uses color names followed by a number for shade, like red-500.
Step 2: Identify correct border color class
The correct format for border color is border-{color}-{shade}, so border-red-500 is correct.
Final Answer:
border-red-500 -> Option A
Quick Check:
Border color uses border-{color}-{shade} format [OK]
Hint: Use border-color-shade format for colors [OK]
Common Mistakes:
Using border-color-red which is invalid
Using just border-red without shade
Using non-Tailwind class names
2. Which class correctly applies a dashed border style in Tailwind?
easy
A. border-dash
B. border-dashed
C. border-style-dashed
D. dashed-border
Solution
Step 1: Recall Tailwind border style classes
Tailwind uses border-solid, border-dashed, border-dotted for border styles.
Step 2: Match correct class
border-dashed is the correct class to apply dashed border style.
Final Answer:
border-dashed -> Option B
Quick Check:
Border style classes start with border- + style [OK]
Hint: Border styles use border- + style name [OK]
Common Mistakes:
Using border-dash which is not valid
Adding extra words like border-style-dashed
Using non-Tailwind class names
3. What border style and color will this div have?
border-green is incomplete; Tailwind requires a shade like border-green-500.
Step 2: Verify other classes
border-2 and border-solid are valid classes.
Final Answer:
Missing shade number in border color class -> Option D
Quick Check:
Border color needs shade number like -500 [OK]
Hint: Always add shade number to color classes [OK]
Common Mistakes:
Omitting shade number in color class
Using invalid style class names
Confusing border width units
5. You want a responsive border that is solid red on small screens and dashed blue on medium and larger screens. Which class combination achieves this?
hard
A. border border-red-600 border-solid md:border-blue-600 md:border-dashed
B. border border-red-600 border-dashed md:border-blue-600 md:border-solid
C. border border-blue-600 border-solid md:border-red-600 md:border-dashed
D. border border-red-600 md:border-blue-600 border-dashed md:border-solid
Solution
Step 1: Set default small screen styles
Use border-red-600 and border-solid for small screens (default).
Step 2: Override on medium screens and up
Use md:border-blue-600 and md:border-dashed to change color and style on medium+ screens.
Final Answer:
border border-red-600 border-solid md:border-blue-600 md:border-dashed -> Option A
Quick Check:
Default solid red, medium+ dashed blue with md: prefix [OK]
Hint: Use md: prefix to change styles on medium screens [OK]