HTML DOM Style border properties
Definition and Usage
border shorthand property to set or return three separate border properties.
With this property, you can set / return:
- border-width
- border-style
- border-color
grammar
Setting border properties:
Object.style.border="width style color"
Returns border properties:
Object.style.border
Tip: border property has no default value.
参数 | 描述 |
---|---|
width | 设置边框的宽度。 |
style | 设置边框的样式。 |
color | 设置边框的颜色。 |
Browser Support
All major browsers support border properties.
Examples
Examples
Change div element border:
<! DOCTYPE html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Style type = "text / css">
# Ex1 {
border: thin dotted # FF0000;
}
</ Style>
<Script>
function displayResult () {
. Document.getElementById ( "ex1") style.border = "thick solid # 0000FF";
}
</ Script>
</ Head>
<Body>
<Div id = "ex1"> This is some text. </ Div>
<br>
<Button type = "button" onclick = "displayResult ()"> Modify Border </ button>
</ Body>
</ Html>
<Html>
<Head>
<Meta charset = "utf-8">
<Title> This tutorial (w3big.com) </ title>
<Style type = "text / css">
# Ex1 {
border: thin dotted # FF0000;
}
</ Style>
<Script>
function displayResult () {
. Document.getElementById ( "ex1") style.border = "thick solid # 0000FF";
}
</ Script>
</ Head>
<Body>
<Div id = "ex1"> This is some text. </ Div>
<br>
<Button type = "button" onclick = "displayResult ()"> Modify Border </ button>
</ Body>
</ Html>
try it"
Style Objects