Contact Us | +1 888 239-0733 (Toll free US/CA) Mon-Fri: 7:30am to 4:30pm (PST)

CSS 'border-color' Property Explained

Est. Reading: 2 minutes
Posted: April 5, 2024

The CSS 'border-color' property specifies the color of an element's border. It can simultaneously set the color for all four borders or target each border individually with one to four color values. This property is essential for defining the visual boundaries of elements, enhancing usability, and contributing to the aesthetic appeal of web designs.

CSS 'border-color' Property Examples

See the Pen CSS 'border-color' Property by Webzstore (@webzstore) on CodePen.

The 'background' shorthand property offers a powerful and flexible way to style the background of elements. It supports a wide range of visual effects with concise syntax, making it essential for designers and developers who want to create engaging and visually rich web interfaces.

Browser Support For 'border-color' Property

FirefoxSafariChromeMicrosoft EdgeOpera
1.01.01.04.03.5

CSS Syntax of the 'border-color' Property

border-color: color | transparent | initial | inherit;
  • When specifying one color, all four borders inherit this color.
  • Two colors define the top and bottom borders with the first color and the right and left borders with the second.
  • Three colors set the top border with the first color, the right and left with the second, and the bottom border with the third.
  • Four colors apply to the borders of the top, right, bottom, and left.

Usage of the 'border-color' Property

Use 'border-color' to customize the color of borders surrounding an element. This versatile property allows for uniform color application across all borders or specifies different colors for the top, right, bottom, and left borders. It's particularly useful in distinguishing elements, improving visual hierarchy, or simply adding decorative flair to a webpage.

Property Values of the 'border-color' Property

  • Color: Sets the border color using any standard CSS color format (named colors, HEX, RGB(a), HSL(a)).
  • Transparent: Makes the border transparent.
  • Initial: Resets the 'border-color' to its default value.
  • Inherit: The element inherits the 'border-color' from its parent element.

Ryan Parker

Ryan has been a standout in digital marketing since 2010. He's the go-to person for getting businesses noticed online, with over 300 projects under his belt—these range from helping local business owners to big online stores. As the Head of Digital Marketing at his company, Ryan knows all the tricks to make companies shine on the internet. He's excellent at using the latest tech and smart strategies to get results. Ryan is all about making businesses grow and reach more people online.

chevron-down