Style borderTopProperty

Style 对象参考手册Style Object

Definition and Usage

The borderTop property sets or returns the three individual top border properties in shorthand form.

Through this property, you can set/return:

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

Syntax

Setting the borderTop property:

Object.style.borderTop="width style color"

Returning the borderTop property:

Object.style.borderTop

Tip:The borderTop property has no default value.

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


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the borderTop property.


Example

Example

Change the width, style, and color of the top border:

<!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.borderTop="thick solid #0000FF";
}
</script>
</head>
<body>

<div id="ex1">This is some text.</div>
<br>
<button type="button" onclick="displayResult()">Modify top border</button>

</body>
</html>

Try it yourself »


Style 对象参考手册Style Object Other Extensions