Style borderStyleProperty

Style 对象参考手册Style Object

Definition and Usage

The borderStyle property sets or returns the style of an element's border.

This property can take from 1 to 4 styles:

  • If one style is specified, for example: p {border-style: solid} - all four borders are solid.
  • If two styles are specified, for example: p {border-style: solid dotted} - the top and bottom borders are solid, while the left and right borders are dotted.
  • If three styles are specified, for example: p {border-style: solid dotted double} - the top border is solid, the left and right borders are dotted, and the bottom border is double.
  • If four styles are specified, for example: p {border-style: solid dotted double dashed} - the top border is solid, the right border is dotted, the bottom border is double, and the left border is dashed.

Syntax

Setting the borderStyle property:

Object.style.borderStyle="value"

Returning the borderStyle property:

Object.style.borderStyle

Value Description
none Default. Defines no border.
hidden Same as "none". Except when applied to tables, for which hidden is used to resolve border conflicts.
dotted Defines a dotted border.
dashed Defines a dashed border.
solid Defines a solid border.
double Defines a double border. The width of the double line equals the value of border-width.
groove Defines a 3D grooved border. The effect depends on the value of border-color.
ridge Defines a 3D ridged border. The effect depends on the value of border-color.
inset Defines a 3D inset border. The effect depends on the value of border-color.
outset Defines a 3D outset border. The effect depends on the value of border-color.
inherit The style of the border is inherited from the parent element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the borderStyle property.

Note:IE7 and earlier versions do not support the "inherit" value. IE8 supports "inherit" only if a !DOCTYPE is specified. IE9 supports "inherit".


Example

Example

Change the style of four borders:

<html>
<head>
<style type="text/css">
#ex1
{
border: thick solid #FF0000;
}
</style>
<script>
function displayResult()
{
document.getElementById("ex1").style.borderStyle="dotted double";
}
</script>
</head>
<body>

<div id="ex1">This is some text.</div>
<br>
<button type="button" onclick="displayResult()">Change style of the four borders</button>

</body>
</html>

Try it yourself »


Style 对象参考手册Style Object Other Extensions