border-top-color

  • Revision slug: Web/CSS/border-top-color
  • Revision title: border-top-color
  • Revision id: 494053
  • Created:
  • Creator: kscarfone
  • Is current revision? Yes
  • Comment Updated tags

Revision Content

{{CSSRef("CSS Borders")}}

Summary

The border-top-color CSS property sets the color of the top border of an element. Note that in many cases the shorthand CSS properties {{cssxref("border-color")}} or {{cssxref("border-top")}} are more convenient and preferable.

{{cssbox("border-top-color")}}

Syntax

Formal syntax: {{csssyntax("border-top-color")}}
border-top-color: red
border-top-color: rgb(255, 128, 0)
border-top-color: hsla(100%, 50%, 25%, 0.75)
border-top-color: #ffbb00
border-top-color: currentColor
border-top-color: transparent

border-top-color: inherit

Values

<color>
Is a {{Xref_csscolorvalue}} CSS value describing the color of the top border.
inherit
Is a keyword denoting the color of the top border of the parent's element (which may be different from the border-top-color default value)

Examples

pre {
    border: solid 0.3em gold;
    border-top-color: red;
}
/* this has the same result:
pre {
        border: solid 0.3em;
        border-color: red gold gold; 
} */

Specifications

Specification Status Comment
{{SpecName('CSS3 Backgrounds', '#border-top-color', 'border-top-color')}} {{Spec2('CSS3 Backgrounds')}} No significant changes, though the transparent keyword, now included in {{xref_csscolorvalue}} which has been extended, has been formally removed.
{{SpecName('CSS2.1', 'box.html#border-color-properties', 'border-top-color')}} {{Spec2('CSS2.1')}} Initial definition.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 1.0 {{CompatGeckoDesktop("1.0")}} [1] 4 3.5 1.0 (85)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support 1.0 {{CompatGeckoMobile("1.0")}} [1] {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}}

[1] Gecko-based browsers like Firefox also supports the non-standard {{Cssxref("-moz-border-top-colors")}} CSS properties that sets the top border to multiple colors.

See also

  • The border-related CSS shorthand properties {{Cssxref("border")}}, {{Cssxref("border-top")}}, and {{Cssxref("border-color")}}.
  • The color-related CSS properties applying to the other borders: {{Cssxref("border-right-color")}}, {{Cssxref("border-bottom-color")}}, and {{Cssxref("border-left-color")}}.
  • The other border-related CSS properties applying to the same border: {{cssxref("border-top-style")}} and {{cssxref("border-top-width")}}.

Revision Source

<div>
 {{CSSRef("CSS Borders")}}</div>
<h2 id="Summary">Summary</h2>
<p>The <code>border-top-color</code> CSS property sets the color of the top border of an element. Note that in many cases the shorthand CSS properties {{cssxref("border-color")}} or {{cssxref("border-top")}} are more convenient and preferable.</p>
<p>{{cssbox("border-top-color")}}</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="/en-US/docs/CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("border-top-color")}}
</pre>
<pre>
border-top-color: red
border-top-color: rgb(255, 128, 0)
border-top-color: hsla(100%, 50%, 25%, 0.75)
border-top-color: #ffbb00
border-top-color: currentColor
border-top-color: transparent

border-top-color: inherit
</pre>
<h3 id="Values">Values</h3>
<dl>
 <dt>
  &lt;<code>color&gt;</code></dt>
 <dd>
  Is a {{Xref_csscolorvalue}} CSS value describing the color of the top border.</dd>
 <dt>
  inherit</dt>
 <dd>
  Is a keyword denoting the color of the top border of the parent's element (which may be different from the <code>border-top-color</code> default value)</dd>
</dl>
<h2 id="Examples">Examples</h2>
<pre style="border-style: solid; border-color: red gold gold; border-width: 0.3em;">
pre {
    border: solid 0.3em gold;
    border-top-color: red;
}
/* this has the same result:
pre {
        border: solid 0.3em;
        border-color: red gold gold; 
} */
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('CSS3 Backgrounds', '#border-top-color', 'border-top-color')}}</td>
   <td>{{Spec2('CSS3 Backgrounds')}}</td>
   <td>No significant changes, though the <code>transparent</code> keyword, now included in {{xref_csscolorvalue}} which has been extended, has been formally removed.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'box.html#border-color-properties', 'border-top-color')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<div>
 {{CompatibilityTable}}</div>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Chrome</th>
    <th>Firefox (Gecko)</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari (WebKit)</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{CompatGeckoDesktop("1.0")}} [1]</td>
    <td>4</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>Android</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>IE Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>1.0</td>
    <td>{{CompatGeckoMobile("1.0")}} [1]</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
    <td>{{CompatVersionUnknown}}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>[1] Gecko-based browsers like Firefox also supports the non-standard {{Cssxref("-moz-border-top-colors")}} CSS properties that sets the top border to <strong>multiple</strong> colors.</p>
<h2 id="See_also">See also</h2>
<ul>
 <li>The border-related CSS shorthand properties {{Cssxref("border")}}, {{Cssxref("border-top")}}, and {{Cssxref("border-color")}}.</li>
 <li>The color-related CSS properties applying to the other borders: {{Cssxref("border-right-color")}}, {{Cssxref("border-bottom-color")}}, and {{Cssxref("border-left-color")}}.</li>
 <li>The other border-related CSS properties applying to the same border: {{cssxref("border-top-style")}} and {{cssxref("border-top-width")}}.</li>
</ul>
Revert to this revision