Javascript DOM CSS Style borderTopRightRadius Property set

Introduction

Add a rounded border to the top-right corner of a div element:

document.getElementById("myDIV").style.borderTopRightRadius = "25px";

Click the button to change the borderTopRightRadius property of the DIV element:

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {//from w  ww  .j  av a 2  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.borderTopRightRadius = "25px";
}
</script>

</body>
</html>

The borderTopRightRadius property defines the radius of the border for the top-right corner.

The first value is the horizontal radius, the second the vertical radius.

If the second value is omitted it is copied from the first.

If either length is zero, the corner is square, not rounded.

Percentages for the horizontal radius refer to the width of the border box.

Percentages for the vertical radius refer to the height of the border box.

Property Values

Value Description
length Defines the shape of the top-right corner
% Defines the shape of the top-right corner in %
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

The borderTopRightRadius property returns a String, representing the border-top-right-radius property of an element.




PreviousNext

Related