borderRadius Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:borderRadius

Description

The borderRadius property is a shorthand property for setting, or returning, the four border Radius properties.

The four values for each radii are given in the order top-left, top-right, bottom-right, bottom-left.

  • If bottom-left is omitted it is the same as top-right.
  • If bottom-right is omitted it is the same as top-left.
  • If top-right is omitted it is the same as top-left.

Property Values

Value Description
length Radii in length. Default value is 0
% Radii in percentage
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

Technical Details

Item Value
Default Value: 0
Return Value: A String, representing the border-radius property of an element
CSS VersionCSS3

Set rounded borders to a div element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {/*  w w  w . j a v  a2 s .  c om*/
    border: 1px solid black;
    width: 300px;
    height: 300px;
}
</style>
</head>
<body>

<button onclick="myFunction()">Test</button>

<div id="myDIV">
  <h1>Hello</h1>
</div>

<script>
function myFunction() {
    document.getElementById("myDIV").style.borderRadius = "25px";
}
</script>

</body>
</html>

Related Tutorials