CSS Property: border-radius
[this page | pdf | back links]
The CSS (CSS1) border-radius property is used to add
rounded corners to an element. It is a shorthand way of
setting the four individual border radius properties, see:
-
border-top-left-radius
-
border-top-right-radius
-
border-bottom-right-radius
-
border-bottom-left-radius
Valid property values (other than inherit and initial) are
(single-value versions) of the valid properties for each of these individual
elements.
Default Value:
|
0
|
JavaScript syntax:
|
e.g. object.style.borderRadius="4px"
|
Inherited:
|
No
|
Animatable:
|
Yes
|
Depending on the number of values supplied:
Number supplied
|
E.g.
|
Which values are applied to which corners
|
1
|
x1
|
x1 applied to all four corners
|
2
|
x1 x2
|
x1 applied to top-left and bottom-right corners
x2 applied to top-right and bottom-left corners
|
3
|
x1 x2 x3
|
x1 applied to top-left corner
x2 applied to top-right and bottom-left corners
x3 applied to bottom-right corner
|
4
|
x1 x2 x3 x4
|
x1 applied to top-left corner
x2 applied to top-right corner
x3 applied to bottom-right corner
x4 applied to bottom-left corner
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
p {border: thin solid black; width: 200px}
p.x1 {border-radius: 10px 5px;}
</style>
</head>
<body>
<p>Element 1: a paragraph with a common border property (i.e. thin, solid, black)</p>
<p class="x1">Element 2: a paragraph with a curved corners</p>
<p id="x2">Element 3: as per Element 2 but set using JavaScript</p>
<script>
document.getElementById("x2").style.borderRadius = "10px 5px";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyBorderRadius() {
var x = document.createElement("DIV"); x.style.borderRadius = "10px 5px"; return (window.getComputedStyle(x, null).borderRadius == "10px 5px");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties