Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

border-top-color — top border color

The border-top-color property sets the color of the physical top border. It does not set the border's width or style, and it leaves the other sides unchanged.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

/* Level 3 */
border-top-color: <color>;
/* Level 4 draft */
border-top-color: <color> | <image-1D>;

border-top-color controls the physical top border's color, regardless of writing direction. In Level 3 it accepts one <color> value, such as #0066cc, transparent, or currentColor. Unlike the border-color shorthand, it does not set all four sides' colors.

The initial value is currentColor, meaning the color supplied by that element's color property. The property is not inherited. Color alone does not produce a line: a nonzero width and a visible style such as solid are necessary; the initial style, none, makes the used width zero. transparent does not remove the space occupied by the border.

The example first sets all sides using border, then changes only the top color. Keep that order: a later border or border-top shorthand can reset the color.

The Level 4 draft extends the syntax with <image-1D> for color bands. This is a draft extension, not a claim of Chromium 152 support; it requires separate verification. The example uses only a <color> value.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>border-top-color</title>
<style>
  .sample {
    width: 160px;
    height: 60px;
    background: white;
    border: 6px solid black;
    border-top-color: #0066cc;
  }
</style>
<div class="sample"></div>
</html>

Result

A white rectangle with a 6px solid blue (#0066cc) top border and 6px solid black borders on the other three sides.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources