How do i fade the border color in css?

The border-top-color CSS property sets the color of an element's top border. It can also be set with the shorthand CSS properties border-color or border-top.

Try it

Syntax

/* <color> values */
border-top-color: red;
border-top-color: #ffbb00;
border-top-color: rgb(255, 0, 0);
border-top-color: hsla(100%, 50%, 25%, 0.75);
border-top-color: currentcolor;
border-top-color: transparent;

/* Global values */
border-top-color: inherit;
border-top-color: initial;
border-top-color: revert;
border-top-color: revert-layer;
border-top-color: unset;

The border-top-color property is specified as a single value.

Values

<color>

The color of the top border.

Formal definition

Formal syntax

border-top-color = 
<color>

Examples

A simple div with a border

HTML

<div class="mybox">
  <p>
    This is a box with a border around it. Note which side of the box is
    <span class="redtext">red</span>.
  </p>
</div>

CSS

.mybox {
  border: solid 0.3em gold;
  border-top-color: red;
  width: auto;
}

.redtext {
  color: red;
}

Result

Specifications

Specification
CSS Backgrounds and Borders Module Level 3
# border-color

Browser compatibility

BCD tables only load in the browser

See also

  • The border-related CSS shorthand properties: border, border-top, and border-color.
  • The color-related CSS properties for the other borders: border-right-color, border-bottom-color, and border-left-color.
  • The other border-related CSS properties applying to the same border: border-top-style and border-top-width.


Example

Set a color for the left border:

div {border-left-color: coral;}

Try it Yourself »

More "Try it Yourself" examples below.


Definition and Usage

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

Note: Always declare the border-style or the border-left-style property before the border-left-color property. An element must have a border before you can change the color.

Show demo ❯

Default value:The current color of the element
Inherited:no
Animatable:yes. Read about animatable Try it
Version:CSS1
JavaScript syntax: object.style.borderLeftColor="blue" Try it


Browser Support

The numbers in the table specify the first browser version that fully supports the property.

Property
border-left-color 1.0 4.0 1.0 1.0 3.5



CSS Syntax

border-left-color: color|transparent|initial|inherit;

Property Values

ValueDescriptionDemo
color Specifies the color of the left border. Look at CSS Color Values for a complete list of possible color values. Default color is the current color of the element Demo ❯
transparent Specifies that the border color should be transparent Demo ❯
initial Sets this property to its default value. Read about initial
inherit Inherits this property from its parent element. Read about inherit


More Examples

Example

Set a color for the left border with a HEX value:

div {border-left-color: #92a8d1;}

Try it Yourself »

Example

Set a color for the left border with an RGB value:

div {border-left-color: rgb(201, 76, 76);}

Try it Yourself »

Example

Set a color for the left border with an RGBA value:

div {border-left-color: rgba(201, 76, 76, 0.3);}

Try it Yourself »

Example

Set a color for the left border with a HSL value:

div {border-left-color: hsl(89, 43%, 51%);}

Try it Yourself »

Example

Set a color for the left border with a HSLA value:

div {border-left-color: hsla(89, 43%, 51%, 0.3);}

Try it Yourself »

Example

Set a transparent left border:

div {border-left-color: transparent;}

Try it Yourself »


CSS tutorial: CSS Border

CSS reference: border-left property

HTML DOM reference: borderLeftColor property



How do you blur a border in CSS?

Blurred Border If you want to visually blur the border of an element, use a pseudo-element, put it behind the parent element with z-index , apply a transparent border, add the background-clip , filter , and clip-path properties.

How do you color a half border in CSS?

Use two gradients: one rotated 90deg and the other rotated -90deg. Use two color stops: #880015 at 50% and #fff at 50% Use a background-size of 100% width and 3px in height, i.e. background-size: 100% 3px. Position the two backgrounds at the top left and bottom left of your element.

How do I create a border gradient in CSS?

To show gradients for a border with CSS you can use the border-image property. It allows setting gradient values in the same way as the background-image property. Besides the border-image property, you should specify additional properties to actually show border gradient.

How do I fade the border of an image in CSS?

Blurring the edges of a photo in CSS is pretty straightforward, with one gotcha. To blur a photo we need to use box-shadow in a way where the shadow "eats" the image. For this effect to work, the blur must be the same color as the surrounding background, and inset must be used.