borderTop Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderTop

Description

The borderTop property sets or gets border-top properties in a shorthand form:

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

Property Values

Parameter 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
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: not specified
Return Value: A String, representing the width, style and/or color of the top border of an element
CSS VersionCSS1

Get a top border of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="border-top:thick solid red">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Return the width of the top border</button>

<script>
function myFunction() {//  www.  jav  a  2 s.c o  m
    console.log(document.getElementById("myDiv").style.borderTopWidth);
}
</script>

</body>
</html>

Related Tutorials