Style borderProperty

Style 对象参考手册Style Object

Definition and Usage

The border property sets or returns three separate border properties in shorthand form.

With this property, you can set/return:

  • border-width
  • border-style
  • border-color

Syntax

Setting the border property:

Object.style.border="width style color"

Returning the border property:

Object.style.border

Tip:The border property has no default value.

Parameters Description
width Sets the width of the border.
style Sets the style of the border.
color Sets the color of the border.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the border property.


Example

Example

Change the border of the div element:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.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 yourself »


Style 对象参考手册Style Object Other Extensions