border-color

  • Revision slug: CSS/border-color
  • Revision title: border-color
  • Revision id: 20937
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment no changes

Revision Content

{{ CSSRef() }}

Summary

The border-color CSS property is a shorthand for setting the color of the four sides of an element's border: {{ cssxref("border-top-color") }}, {{ cssxref("border-right-color") }}, {{ cssxref("border-bottom-color") }}, {{ cssxref("border-left-color") }}

  • {{ Xref_cssinitial() }}: as for any shorthand property, its initial value is the one of each of its of the property it can replace. In that case, it is each time {{ cssxref("currentColor") }}, the element's {{ Cssxref("color") }} property.
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: no
  • Percentages: N/A
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: the computed value of color by default, or as specified.

Syntax

border-color:  color                 /* one-value syntax */ 
border-color:  horizontal vertical   /* two-value syntax */
border-color:  top vertical bottom   /* three-value syntax */
border-color:  top right bottom left /* four-value syntax */
border-color:  inherit

where :

color
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all four edges. It is used only in the one-value syntax.
horizontal
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all horizontal edges, that is the top and bottom edges. It is used only in the two-value syntax.
vertical
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all vertical edges, that is the right and left edges. It is used only in the two- and three-value syntaxes.
top
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the three- and four-value syntaxes.
bottom
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the bottom edge. It is used only in the three- and four-value syntaxes.
right
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the four-value syntax.
left
Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the four-value syntax.
inherit
Is a keyword indicating that all four values are inherited from their parent's element calculated value.

Examples

{{ CSSRefExampleLink("border") }}

pre { 
  border-style: ridge dashed solid;
  border-color: orange blue;
}

Specifications

Specification Status Comment
CSS Backgrounds and Borders Module Level 3 {{ Spec2('CSS3 Backgrounds') }} The transparent keyword has been removed as it is now a part of {{ xref_csscolorvalue() }} data type.
CSS 2.1 {{ Spec2('CSS2.1') }} The property is now a shorthand property
CSS 1 {{ Spec2('CSS1') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatGeckoDesktop("1.0") }} [1] 1.0 4.0 3.5 1.0 (85)
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatGeckoMobile("1.9.2") }} [1] {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

[1] The following Mozilla extensions set the border sides to multiple colors for Gecko based browsers like Firefox. {{ Cssxref("-moz-border-top-colors") }}, {{ Cssxref("-moz-border-right-colors") }}, {{ Cssxref("-moz-border-bottom-colors") }}, {{ Cssxref("-moz-border-left-colors") }}

See also

  • Border-color related CSS properties: {{ Cssxref("border") }}, {{ cssxref("border-top-color") }}, {{ cssxref("border-right-color") }}, {{ cssxref("border-bottom-color") }}, {{ cssxref("border-left-color") }},
  • Other border-related CSS properteis: {{ Cssxref("border-width") }}, {{ Cssxref("border-style") }}

{{ languages( { "de": "de/CSS/border-color", "es": "es/CSS/border-color", "fr": "fr/CSS/border-color", "ja": "ja/CSS/border-color", "pl": "pl/CSS/border-color" } ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<h2>Summary</h2>
<p>The<code> border-color </code>CSS property is a shorthand for setting the color of the four sides of an element's border: {{ cssxref("border-top-color") }}, {{ cssxref("border-right-color") }}, {{ cssxref("border-bottom-color") }}, {{ cssxref("border-left-color") }}</p>
<ul class="cssprop"> <li>{{ Xref_cssinitial() }}: as for any shorthand property, its initial value is the one of each of its of the property it can replace. In that case, it is each time {{ cssxref("currentColor") }}, the element's {{ Cssxref("color") }} property.</li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: no</li> <li>Percentages: N/A</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: the computed value of <code>color</code> by default, or as specified.</li>
</ul>
<h2>Syntax</h2>
<pre class="syntaxbox">border-color:  <em>color</em>     <em>            /* one-value syntax */ 
</em>border-color:  <em>horizontal vertical   /* two-value syntax */
</em>border-color:  <em>top</em> <em>vertical</em> <em>bottom   /* three-value syntax */</em>
border-color: <em> top right bottom left /* four-value syntax */</em>
border-color:  inherit
</pre>
<p>where :</p>
<dl> <dt><em>color</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all four edges. It is used only in the one-value syntax.</dd> <dt><em>horizontal</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all horizontal edges, that is the top and bottom edges. It is used only in the two-value syntax.</dd> <dt><em>vertical</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to all vertical edges, that is the right and left edges. It is used only in the two- and three-value syntaxes.</dd> <dt><em>top</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the three- and four-value syntaxes.</dd> <dt><em>bottom</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the bottom edge. It is used only in the three- and four-value syntaxes.</dd> <dt><em>right</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the four-value syntax.</dd> <dt><em>left</em></dt> <dd>Is a  {{ Xref_csscolorvalue() }} denoting the color to apply to the top edge. It is used only in the four-value syntax.</dd> <dt>inherit</dt> <dd>Is a keyword indicating that all four values are inherited from their parent's element calculated value.</dd>
</dl>
<h2>Examples</h2>
<p>{{ CSSRefExampleLink("border") }}</p>
<pre style="border-style: ridge dashed solid; border-color: orange blue; border-width: medium;">pre { 
  border-style: ridge dashed solid;
  border-color: orange blue;
}</pre>
<h2>Specifications</h2>
<table class="standard-table"> <thead> <tr style="background-color: rgb(255, 204, 255);"> <th scope="col">Specification</th> <th scope="col">Status</th> <th scope="col">Comment</th> </tr> </thead> <tbody> <tr> <td><a class="external" href="http://www.w3.org/TR/css3-background/#the-border-color" title="http://www.w3.org/TR/css3-background/#the-border-color">CSS Backgrounds and Borders Module Level 3</a></td> <td>{{ Spec2('CSS3 Backgrounds') }}</td> <td>The <code>transparent</code> keyword has been removed as it is now a part of {{ xref_csscolorvalue() }} data type.</td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS21/box.html#border-color-properties" title="http://www.w3.org/TR/CSS21/box.html#border-color-properties">CSS 2.1</a></td> <td>{{ Spec2('CSS2.1') }}</td> <td>The property is now a shorthand property</td> </tr> <tr> <td><a class="external" href="http://www.w3.org/TR/CSS1/#border-color" title="http://www.w3.org/TR/CSS1/#border-color">CSS 1</a></td> <td>{{ Spec2('CSS1') }}</td> <td> </td> </tr> </tbody>
</table>
<h2>Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Firefox (Gecko)</th> <th>Chrome</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatGeckoDesktop("1.0") }} [1]</td> <td>1.0</td> <td>4.0</td> <td>3.5</td> <td>1.0 (85)</td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Firefox Mobile (Gecko)</th> <th>Android</th> <th>IE Phone</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatGeckoMobile("1.9.2") }} [1]</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<p>[1] The following Mozilla extensions set the border sides to <strong>multiple</strong> colors for Gecko based browsers like Firefox. {{ Cssxref("-moz-border-top-colors") }}, {{ Cssxref("-moz-border-right-colors") }}, {{ Cssxref("-moz-border-bottom-colors") }}, {{ Cssxref("-moz-border-left-colors") }}</p>
<h2>See also</h2>
<ul> <li>Border-color related CSS properties: {{ Cssxref("border") }}, {{ cssxref("border-top-color") }}, {{ cssxref("border-right-color") }}, {{ cssxref("border-bottom-color") }}, {{ cssxref("border-left-color") }},</li> <li>Other border-related CSS properteis: {{ Cssxref("border-width") }}, {{ Cssxref("border-style") }}</li>
</ul>
<p>{{ languages( { "de": "de/CSS/border-color", "es": "es/CSS/border-color", "fr": "fr/CSS/border-color", "ja": "ja/CSS/border-color", "pl": "pl/CSS/border-color" } ) }}</p>
Revert to this revision