HTML DOM Style borderColor property
Definition and Usage
borderColor property sets or returns the color of an element's border.
This property can be used 1-4 kinds of colors:
- If you specify a color, for example: p {border-color: red} - all four borders are red.
- If you specify two colors, for example: p {border-color: red transparent} - upper and bottom borders are red, and the left and right border of the box is transparent.
- If the provisions of the three colors, for example: p {border-color: red green blue} - red border, left border and right border is green, the bottom border is blue.
- If the provisions of four colors, for example: p {border-color: red green blue yellow} - on the border are red, green box on the right, under the blue border, left border is yellow.
grammar
Setting borderColor properties:
Object.style.borderColor="color|transparent|inherit"
Back borderColor properties:
Object.style.borderColor
值 | 描述 |
---|---|
color | 规定边框的颜色。在 CSS 颜色值 中寻找可能的颜色值的完整列表。 |
transparent | 默认。边框的颜色是透明的(基本内容将会穿透)。 |
inherit | 边框的颜色从父元素继承。 |
Browser Support
All major browsers support borderColor property.
Note: IE7 and earlier versions do not support the "inherit" value.IE8 only provides! DOCTYPE supported "inherit". IE9 support "inherit".
Examples
Examples
Change the color of the four borders:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Style type = "text / css">
# Ex1 {
border: thick solid # FF0000;
}
</ Style>
<Script>
function displayResult () {
document.getElementById ( "ex1") style.borderColor = "# 00FF00 # 0000FF".;
}
</ Script>
</ Head>
<Body>
<Div id = "ex1"> This is some text. </ Div>
<br>
<Button type = "button" onclick = "displayResult ()"> change the color of the four borders </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Style type = "text / css">
# Ex1 {
border: thick solid # FF0000;
}
</ Style>
<Script>
function displayResult () {
document.getElementById ( "ex1") style.borderColor = "# 00FF00 # 0000FF".;
}
</ Script>
</ Head>
<Body>
<Div id = "ex1"> This is some text. </ Div>
<br>
<Button type = "button" onclick = "displayResult ()"> change the color of the four borders </ button>
</ Body>
</ Html>
try it"
Style Objects