Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

Border on One Side

In CSS, you drew a line on one side only with border-top, border-bottom and the like. In Tailwind, you add the side's letter after border-, followed by the width if the line shouldn't be 1 pixel wide:

ClassCSS
border-tborder-top-width: 1px;
border-rborder-right-width: 1px;
border-b-2border-bottom-width: 2px;
border-l-4border-left-width: 4px;
border-xborder-left-width: 1px;
border-right-width: 1px;
border-yborder-top-width: 1px;
border-bottom-width: 1px;

You know the side letters from padding (pt-4, px-6): t is top, r right, b bottom, l left, x left and right, and y top and bottom.

The color class doesn't need a side: border-orange-300 colors all four sides, and only the ones that have a width are visible. (If two sides should have different colors, there are classes such as border-t-orange-500.)

A line on one side often separates things: border-b under a heading, border-t above the buttons at the bottom of a card. A thicker colored line on the left marks a quote or an important note. Let's give Oscar's description that look.

Instructions

  1. 1

    Add the class border-l-4 to the paragraph with Oscar's description ("A brave explorer..."). A 4-pixel line appears along its left edge, and it's dark again: it has the paragraph's text color.

  2. 2

    Add the class border-orange-300, which colors the line orange, and pl-3, so that the text doesn't touch the line.

Back

2/10

  1. 1. Borders
  2. 2. Border on One Side
  3. 3. Rounded Corners
  4. 4. Shadows
  5. 5. Images
  6. 6. Aspect Ratio
  7. 7. Rounded Corners on Pictures
  8. 8. Opacity
  9. 9. A Card from Scratch
  10. 10. Summary
Next

Try it yourself

Do this exercise right here in your browser. No account needed.