Style borderTopColorProperty

Style 对象参考手册Style Object

Definition and Usage

The borderTopColor property sets or returns the color of the top border of an element.

Syntax

Set the borderTopColor property:

Object.style.borderTopColor="color|transparent|inherit"

Return the borderTopColor property:

Object.style.borderTopColor

Tip:The borderTopColor property has no default value.

Value Description
color Specifies the color of the top border. SeeCSS color valuesfor a complete list of possible color values.
transparent The color of the top border is transparent (the underlying content will show through).
inherit The color of the top border is inherited from the parent element.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the borderTopColor property.

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


Examples

Examples

Change the color of the top border:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Example Tutorial (example.com)</title>
<style type="text/css">
#ex1{
    border: 1px solid #FF0000;
}
</style>
<script>
function displayResult(){
    document.getElementById("ex1").style.borderTopColor="#0080FF";
}
</script>
</head>
<body>

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

</body>
</html>

Try it Yourself »


Style 对象参考手册Style Object Other Extensions