Javascript DOM CSS Style borderTopLeftRadius Property

Introduction

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

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

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

View in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {//w w  w .  j a  v  a 2 s. c o m
  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.borderTopLeftRadius = "25px";
}
</script>

</body>
</html>

The borderTopLeftRadius property sets or gets radius of the border for the top-left 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-left corner
% Defines the shape of the top-left corner in %
initial Sets this property to its default value.
inherit Inherits this property from its parent element.

The borderTopLeftRadius property returns a String representing the border-top-left-radius property of an element.




PreviousNext

Related