CSS border-bottom-color
Property
The border-bottom-color
property in CSS is used to set the color of the bottom border of an element. It works along with border-bottom-style
and border-bottom-width
to define the complete appearance of the bottom border.
1. Syntax
Accepted Values:
Value | Description |
---|---|
Color Name (red , blue , green ) | Uses predefined color names. |
Hex Code (#ff5733 ) | Uses a hexadecimal color code. |
RGB (rgb(255, 87, 51) ) | Uses red, green, and blue values. |
RGBA (rgba(255, 87, 51, 0.5) ) | Includes transparency (alpha). |
HSL (hsl(10, 100%, 50%) ) | Uses hue, saturation, and lightness. |
HSLA (hsla(10, 100%, 50%, 0.5) ) | Includes transparency. |
transparent | Makes the border color invisible. |
inherit | Inherits the color from the parent element. |
2. Example – Setting Different Bottom Border Colors
✅ Each div
has a different bottom border color.
3. Example – Using border-bottom
Shorthand
Instead of defining border-bottom-width
, border-bottom-style
, and border-bottom-color
separately, you can use the border-bottom
shorthand:
✅ This is equivalent to:
4. Example – Transparent Bottom Border
If you want to hide the bottom border while keeping the space occupied, use transparent
:
✅ The border won't be visible, but the layout remains unchanged.
5. Best Practices
✔ Always specify border-bottom-style
; otherwise, the color won’t be visible.
✔ Use border-bottom
shorthand for cleaner code.
✔ Utilize rgba()
or hsla()
for opacity control.