border Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:border

Description

The border property sets or gets three separate border properties:

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

Property Values

Parameter Description
width Sets the width of the borders
style Sets the style of the borders
color Sets the color of the borders
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 border width, style and/or color
CSS VersionCSS1

Get a border of a <div> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<div id="myDiv" style="border:1px solid black">This is a div element.</div>
<br>
<button type="button" onclick="myFunction()">Test</button>

<script>
function myFunction() {//from w  w w . j av  a 2  s .c  o m
    console.log(document.getElementById("myDiv").style.borderWidth);
}
</script>

</body>
</html>

Related Tutorials