- Services
- Case Studies
- Technologies
- NextJs development
- Flutter development
- NodeJs development
- ReactJs development
- About
- Contact
- Tools
- Blogs
- FAQ
CSS border-top-color Customize Border Colors Easily
Explore options like named colors, hex codes, RGB, RGBA, HSL, HSLA, and shorthand properties.
Description
The border-top-color
property in CSS sets the color of an element’s top border. It’s essential for customizing the appearance of your web pages. You can use various color values like named colors (e.g., red), hex codes (e.g., #ffbb00), RGB, RGBA, HSL, and HSLA. It’s also part of shorthand properties such as border-color
or border-top
. Mastering border-top-color
can significantly improve the aesthetics and user experience of your website.
Syntax
The syntax for the border-top-color
property is straightforward:
Values
The border-top-color
property accepts various values:
- Color Values:
red
#ffbb00
rgb(255 0 0)
hsl(100deg 50% 25% / 75%)
currentcolor
: Uses the current value of thecolor
property.transparent
: Makes the border color transparent.
- Global Values:
inherit
: Inherits the value from the parent element.initial
: Sets the value to its default.revert
: Reverts the value to the user agent’s default.revert-layer
: Reverts the value to the default for the specific layer.unset
: Resets the value to its natural value, which is either its initial value or the inherited value.
Formal Definition
The border-top-color
property has specific characteristics:
Property | Value |
---|---|
Initial Value | currentcolor |
Applies To | All elements. It also applies to ::first-letter . |
Inherited | No |
Computed Value | Computed color |
Animation Type | A color |
Examples
Here are some examples to illustrate how the border-top-color
property can be used:
Simple Div with a Border
HTML
CSS
Clickable Examples
HTML
CSS
Browser Compatibility
The border-top-color
property is widely supported across all major web browsers:
- Chrome: Supported from version 1.0 (released in December 2008).
- Firefox: Supported from version 1.0 (released in November 2004).
- Internet Explorer/Edge: Supported from version 4.0 (released in September 1997).
- Opera: Supported from version 3.5 (released in November 1998).
- Safari: Supported from version 1.0 (released in June 2003).
See Also
For further exploration of related CSS properties, you might find the following resources helpful:
- Border-Related CSS Shorthand Properties:
- Color-Related CSS Properties for Other Borders:
- Other Border-Related CSS Properties:
- Default Color Value:
Related Properties
To fully utilize the border-top-color
property, it’s helpful to understand related CSS properties that can be used in conjunction to achieve the desired border styling. Here are some related properties:
- Border Shorthand Properties:
border
: A shorthand property that sets the width, style, and color of all four borders.border-top
: A shorthand property that sets the width, style, and color of the top border.border-color
: A shorthand property that sets the color of all four borders.
- Color-Related Border Properties:
border-right-color
: Sets the color of the right border.border-bottom-color
: Sets the color of the bottom border.border-left-color
: Sets the color of the left border.
- Other Border-Related Properties:
border-top-style
: Sets the style of the top border.border-top-width
: Sets the width of the top border.
- Default Color Value:
currentcolor
: Uses the current value of thecolor
property.
Talk with CEO
We'll be right here with you every step of the way.
We'll be here, prepared to commence this promising collaboration.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.