border-color
Quick Summary for border-color
The border-color shorthand CSS property sets the color of an element's border.
Code Usage for border-color

<pre class="brush: css notranslate"><code><span class="token comment">/ &lt;color&gt; values /</span> <span class="token property">border-color</span><span class="token punctuation">:</span> red<span class="token punctuation">;</span> <span class="token comment">/ top and bottom | left and right /</span> <span class="token property">border-color</span><span class="token punctuation">:</span> red #f015ca<span class="token punctuation">;</span> <span class="token comment">/ top | left and right | bottom /</span> <span class="token property">border-color</span><span class="token punctuation">:</span> red <span class="token function">rgb</span><span class="token punctuation">(</span>240<span class="token punctuation">,</span>30<span class="token punctuation">,</span>50<span class="token punctuation">,</span>.7<span class="token punctuation">)</span> green<span class="token punctuation">;</span> <span class="token comment">/ top | right | bottom | left /</span> <span class="token property">border-color</span><span class="token punctuation">:</span> red yellow green blue<span class="token punctuation">;</span> <span class="token comment">/ Global values /</span> <span class="token property">border-color</span><span class="token punctuation">:</span> inherit<span class="token punctuation">;</span> <span class="token property">border-color</span><span class="token punctuation">:</span> initial<span class="token punctuation">;</span> <span class="token property">border-color</span><span class="token punctuation">:</span> revert<span class="token punctuation">;</span> <span class="token property">border-color</span><span class="token punctuation">:</span> unset<span class="token punctuation">;</span> </code></pre>

More Details for border-color

border-color

The border-color shorthand CSS property sets the color of an element's border.

Each side can be set individually using border-top-color, border-right-color, border-bottom-color, and border-left-color; or using the writing mode-aware border-block-start-color, border-block-end-color, border-inline-start-color, and border-inline-end-color.

You can find more information about border colors in Borders in Applying color to HTML elements using CSS.

Constituent properties

This property is a shorthand for the following CSS properties:

border-bottom-color border-left-color border-right-color border-top-color

Syntax

/* <color> values */ border-color: red;  /* top and bottom | left and right */ border-color: red #f015ca;  /* top | left and right | bottom */ border-color: red rgb(240,30,50,.7) green;  /* top | right | bottom | left */ border-color: red yellow green blue;  /* Global values */ border-color: inherit; border-color: initial; border-color: revert; border-color: unset; 

The border-color property may be specified using one, two, three, or four values.

When one value is specified, it applies the same color to all four sides. When two values are specified, the first color applies to the top and bottom, the second to the left and right. When three values are specified, the first color applies to the top, the second to the left and right, the third to the bottom. When four values are specified, the colors apply to the top, right, bottom, and left in that order (clockwise).

Values

<color>

Defines the color of the border.

Formal definition

Initial valueas each of the properties of the shorthand:border-top-color: currentcolorborder-right-color: currentcolorborder-bottom-color: currentcolorborder-left-color: currentcolor
Applies toall elements. It also applies to ::first-letter.
Inheritedno
Computed valueas each of the properties of the shorthand:border-bottom-color: computed colorborder-left-color: computed colorborder-right-color: computed colorborder-top-color: computed color
Animation typeas each of the properties of the shorthand:border-bottom-color: a colorborder-left-color: a colorborder-right-color: a colorborder-top-color: a color

Formal syntax

<color>{1,4}

where <color> = <rgb()> | <rgba()> | <hsl()> | <hsla()> | <hwb()> | <hex-color> | <named-color> | currentcolor | <deprecated-system-color>

where <rgb()> = rgb( <percentage>{3} [ / <alpha-value> ]? ) | rgb( <number>{3} [ / <alpha-value> ]? ) | rgb( <percentage>#{3} , <alpha-value>? ) | rgb( <number>#{3} , <alpha-value>? )<rgba()> = rgba( <percentage>{3} [ / <alpha-value> ]? ) | rgba( <number>{3} [ / <alpha-value> ]? ) | rgba( <percentage>#{3} , <alpha-value>? ) | rgba( <number>#{3} , <alpha-value>? )<hsl()> = hsl( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsl( <hue>, <percentage>, <percentage>, <alpha-value>? )<hsla()> = hsla( <hue> <percentage> <percentage> [ / <alpha-value> ]? ) | hsla( <hue>, <percentage>, <percentage>, <alpha-value>? )<hwb()> = hwb( [<hue> | none] [<percentage> | none] [<percentage> | none] [ / [<alpha-value> | none] ]? )

where <alpha-value> = <number> | <percentage><hue> = <number> | <angle>

Examples

Complete border-color usage

HTML
<div id="justone">   <p><code>border-color: red;</code> is equivalent to</p>   <ul><li><code>border-top-color: red;</code></li>     <li><code>border-right-color: red;</code></li>     <li><code>border-bottom-color: red;</code></li>     <li><code>border-left-color: red;</code></li>   </ul> </div> <div id="horzvert">   <p><code>border-color: gold red;</code> is equivalent to</p>   <ul><li><code>border-top-color: gold;</code></li>     <li><code>border-right-color: red;</code></li>     <li><code>border-bottom-color: gold;</code></li>     <li><code>border-left-color: red;</code></li>   </ul> </div> <div id="topvertbott">   <p><code>border-color: red cyan gold;</code> is equivalent to</p>   <ul><li><code>border-top-color: red;</code></li>     <li><code>border-right-color: cyan;</code></li>     <li><code>border-bottom-color: gold;</code></li>     <li><code>border-left-color: cyan;</code></li>   </ul> </div> <div id="trbl">   <p><code>border-color: red cyan black gold;</code> is equivalent to</p>   <ul><li><code>border-top-color: red;</code></li>     <li><code>border-right-color: cyan;</code></li>     <li><code>border-bottom-color: black;</code></li>     <li><code>border-left-color: gold;</code></li>   </ul> </div> 
CSS
#justone {   border-color: red; }  #horzvert {   border-color: gold red; }  #topvertbott {   border-color: red cyan gold; }  #trbl {   border-color: red cyan black gold; }  /* Set width and style for all divs */ div {   border: solid 0.3em;   width: auto;   margin: 0.5em;   padding: 0.5em; }  ul {   margin: 0;   list-style: none; } 
Result

Specifications

Specification
CSS Logical Properties and Values Level 1 # logical-shorthand-keyword
CSS Backgrounds and Borders Module Level 4 # border-color

See also

Border-color related CSS properties: border, border-top-color, border-right-color, border-bottom-color, border-left-color, Other border-related CSS properties: border-width, border-style The <color> data type Other color-related properties: color, background-color, outline-color, text-decoration-color, text-emphasis-color, text-shadow, caret-color, and column-rule-color Applying color to HTML elements using CSS

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)DeutschEspañolFrançais日本語한국어Polski中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
There is a qualitative and quantitative difference between a day that begins with a little exercise, a book, meditation, a good meal, a thoughtful walk, and the start of a day that begins with a smartphone in bed.
Unknown
Latest News
## 🚀 AI Giants Hit Bullseye: Anthropic & OpenAI Achieve Product-Market Fit Anthropic and OpenAI have reached a significant milestone, finding product-market fit with their AI technologies, which means their products effectively meet the needs of their customers, driving growth and adoption. This achievement showcases the practical value of their innovations, enabling businesses and individuals to leverage AI for enhanced productivity and efficiency. With this alignment of product and market needs, these companies are poised to transform industries and shape the future of technology.