CSS border-color Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The border-color property is a shorthand for the four side colors: border-top-color, border-right-color, border-bottom-color, and border-left-color.

Use one color for every side, or up to four colors in clockwise order: top, right, bottom, left. It applies to all elements, including ::first-letter, and it is not inherited. Each side defaults to currentColor (the element’s color). Color alone does not paint a border until border-style is visible.

Standard-track.

Not deprecated. Ordinary <color> values are Baseline. The newer Level 4 stripes() / image-border syntax is experimental and not ready as a sole production value.

CSS Syntax

syntax.css
border-color: <color> | <color> <color> | <color>{3} | <color>{4} | initial | inherit;

One value sets all sides. Two set top/bottom then left/right. Three set top, left/right, bottom. Four set top, right, bottom, left.

Property Values

ValueDescriptionTry it
<color>One color for all four sides (named, hex, rgb(), and more)Try it
Two colorsTop and bottom, then left and rightTry it
Four colorsTop, right, bottom, left in clockwise orderTry it
currentColorUses the element’s text color (also the initial value)Try it
initialResets each side to currentColorTry it
inheritTakes the parent’s border-colorTry it

How to Use border-color

Give the border a visible style and width, then set the color shorthand.

  1. Choose the element that needs a border.
  2. Set border-style (for example solid) and a width greater than zero.
  3. Set border-color with one to four colors.
  4. Or use the border shorthand to set width, style, and color together.
PieceRequired?Role
border-styleYes (to show)Default is none, which hides the border
border-widthYes (to show)Zero width draws nothing
border-colorOptionalDefaults to currentColor if omitted
Side longhandsOptionalOverride one side after the shorthand

Live Preview

The box already has a solid 4px border. Change only border-color and watch the sides update.

Width and style stay fixed. Only the color shorthand changes.

Border

border-color: red

CSS Examples

Each snippet keeps CSS lean: a visible border, then border-color. Use Try It Yourself for a live editor.

Example 1 — One Color

Paint every side with the same color.

CSS
<style>
  p {
    border: 4px solid;
    border-color: red;
  }
</style>

<p>Red border on all sides</p>
Try It Yourself

How It Works

  1. Make the border visible. border: 4px solid sets width and style. Color is still the default currentColor at this point.
  2. Set one color. border-color: red paints top, right, bottom, and left the same.
  3. Shorthand expands. That one value is the same as setting all four side longhands to red.
  4. Order does not matter here. With a single value there is only one color to apply.

Example 2 — Four Colors

Give each side its own color in clockwise order.

CSS
<style>
  p {
    border: 4px solid;
    border-color: red #2563eb #0f766e gold;
  }
</style>

<p>Top, right, bottom, left</p>
Try It Yourself

How It Works

  1. Keep width and style. The solid 4px border is already visible.
  2. List four colors. Order is top, right, bottom, left — the same clock order as margin and padding.
  3. Read the sides. Red is top, blue is right, teal is bottom, gold is left.
  4. Mix formats freely. Named colors and hex values can sit in the same list.

Example 3 — currentColor

Let the border follow the text color automatically.

CSS
<style>
  p {
    color: #2563eb;
    border: 4px solid;
    border-color: currentColor;
  }
</style>

<p>Border matches text color</p>
Try It Yourself

How It Works

  1. Set text color. color: #2563eb makes the words blue.
  2. Draw a solid border. Width and style are set without a fixed color.
  3. Link the border. border-color: currentColor uses that same blue.
  4. Change once, update both. Editing color updates the text and the border together. That is also why the initial border color follows text color.

Edge Cases & Pitfalls

If the border color seems missing or wrong, check these first.

style

Color without style stays invisible

Default border-style is none. Set solid (or another visible style) and a width greater than zero.

order

Four values are clockwise

Remember top, right, bottom, left. Mixing that order with left-to-right thinking is a common mistake.

transparent

transparent still takes space

A transparent border keeps its width in the layout. Use it for hover swaps or alignment tricks, not to remove the border box.

shorthand

border can reset color

A later border shorthand may overwrite your border-color. Set color after the shorthand, or include the color in the shorthand.

non-standard

Avoid -moz-border-*-colors

Firefox-only multi-color side properties are non-standard. Prefer the standard one-to-four value border-color shorthand.

Browser Support

border-color is a browser CSS property for element borders. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

border-color

Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, Internet Explorer 4+. One-to-four color values are long-established.

99% Global support
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 1+
Full support
Microsoft Edge 12+
Full support
Opera 3.5+
Full support
Samsung Internet 1+
Full support
Internet Explorer 4+
Full support
border-color Widely supported

Bottom line: Safe for production. Stick to standard <color> values. Treat Level 4 stripe/image border colors as experimental for now.

Key Takeaways

  • Role: shorthand for the four physical border side colors.
  • Needs style: pair with a visible border-style and width, or use border.
  • Initial value: currentColor on each side. Not inherited.
  • Value count: 1, 2, 3, or 4 colors. Four values go top → right → bottom → left.

One line: border-color paints the border — after style and width make that border visible.

Frequently Asked Questions

It is a shorthand that sets the color of an element's borders. One value paints all four sides. Two, three, or four values set sides in top-right-bottom-left order.
Each side defaults to currentColor, which means the border uses the element's text color until you set a different border color.
Color alone does not draw a border. You also need a visible border-style such as solid and a width greater than zero, or use the border shorthand.
Yes. With four values, colors apply to top, right, bottom, and left in that order. You can also set each side with border-top-color and the other longhands.
No. Set it on the element that needs the border. The initial value still follows currentColor, which tracks that element's color property.
It is Baseline and widely available: Chrome 1+, Firefox 1+, Safari 1+, Edge 12+, and Internet Explorer 4+. It is a browser style property, not a Node.js feature.

Next: border-end-end-radius

Learn the logical corner radius for the end-end corner.

border-end-end-radius tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful