Thuộc tính Style borderColor
- Προηγούμενη σελίδα borderCollapse
- Επόμενη σελίδα borderImage
- Επιστροφή στο προηγούμενο επίπεδο HTML DOM Style Object
Định nghĩa và cách sử dụng
borderColor
Thuộc tính này thiết lập hoặc trả về màu của viền phần tử.
Thuộc tính này có thể sử dụng từ một đến bốn giá trị:
- Một giá trị ví dụ: p {border-color: red} - Tất cả bốn cạnh viền đều là màu đỏ
- Two values, for example: p {border-color: red transparent} - The top and bottom borders are red, and the left and right borders are transparent
- Three values, for example: p {border-color: red green blue} - The top border is red, the left and right borders are green, and the bottom border is blue
- Four values, for example: p {border-color: red green blue yellow} - The top border is red, the right border is green, the bottom border is blue, and the left border is yellow
See Also:
CSS Tutorial:Περιθώρια CSS
CSS Reference Manual:border-color Property
HTML DOM Reference Manual:border Property
Example
Example 1
Changes the color of all four borders of the <div> element to red:
document.getElementById("myDiv").style.borderColor = "red";
Example 2
Changes the color of the top and bottom borders of the <div> element to green, and the color of the left and right borders to purple:
document.getElementById("myDiv").style.borderColor = "green purple";
Example 3
Returns the border color of the <div> element:
alert(document.getElementById("myDiv").style.borderColor);
Syntax
Returns borderColor Property:
object.style.borderColor
Set borderColor Property:
object.style.borderColor = "color|transparent|initial|inherit"
Property Value
Value | Description |
---|---|
color |
Specifies the border color. The default color is black. See CSS Color Values, for a complete list of possible color values. |
transparent | The border color is transparent (the underlying content will show through). |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical Details
Default Value: | black |
---|---|
Return Value: | A string representing the color of the element's border. |
CSS Version: | CSS1 |
Browser Support
The numbers in the table indicate the version of the browser that first fully supports this property.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
1.0 | 4.0 | 1.0 | 1.0 | 3.5 |
- Προηγούμενη σελίδα borderCollapse
- Επόμενη σελίδα borderImage
- Επιστροφή στο προηγούμενο επίπεδο HTML DOM Style Object