CSS border-radius Property

You are Here:

Demo

border-radius: 25px;

CSS border-radius Property

CSS border-radius property rounds the corners of an element's outer border edge.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ border: 1px solid black; width: 150px; height: 150px; line-height: 150px; text-align: center; border-radius: 25px; } </style> </head> <body> <h1>CSS border-radius Property</h1> <div> border-radius: 25px; </div> </body> </html>

Syntax

Using CSS

element{ border-radius: 25px; }

Using Javascript

object.style.borderRadius="25px";

Animatable

Yes, border-radius property is animatable. CSS Animatable Properties Reference.

Default Value

Default value for CSS border-radius property is 0.

Property Value

The following table provides a list of all values for CSS border-radius property.

ValueExplanation
lengthAllows you to define the shape the shape of the corners in any CSS length unit.
%Allows you to define the shape of the corners in %.

Using Percentage Value

Set border-radius to 50% to change a square border to a circle.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ border: 1px solid black; width: 150px; height: 150px; line-height: 150px; text-align: center; border-radius: 50%; } </style> </head> <body> <h1>CSS border-radius Property</h1> <div> border-radius: 50%; </div> </body> </html>

Using JavaScript

In the following example, we will demonstrate how to change the CSS border-radius property of an element using JavaScript.

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ padding: 10px; margin-bottom: 10px; border: 1px solid black; width: 150px; height: 150px; line-height: 150px; } </style> </head> <body> <h1>CSS border-radius Property</h1> <div> This is div container. </div> <button onclick="myFunction()">Click Me</button> <script> var x = document.getElementsByTagName("div")[0]; function myFunction(){ x.style.borderRadius = "50%"; } </script> </body> </html>

CSS border-radius is a shorthand CSS Property

The border-radius is a shorthand CSS Property of the following CSS properties.

The border-radius CSS property can have one, two, three, or four values.

  • border-radius: 50px
    • all four borders are rounded to 50px.
  • border-radius: 50px 10px
    • top-left and bottom-right corners are 50px
    • top-right and bottom-left corners are 10px
  • border-radius: 100px 50px 10px
    • top-left corner is 100px
    • top-right and bottom-left corners are 50px
    • bottom-right corner is 10px
  • border-radius: 150px 100px 50px 10px
    • top-left corner is 150px
    • top-right corner is 100px
    • bottom-right corner is 50px
    • bottom-left corner is 10px

Example

HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <head> <style> div{ border: 1px solid black; width: 280px; height: 280px; line-height: 280px; text-align: center; } #point{ border-radius: 50px; } #point1{ border-radius: 50%; } #point2{ border-radius: 50px 10px; } #point3{ border-radius: 100px 50px 10px; } #point4{ border-radius: 150px 100px 50px 10px; } </style> </head> <body> <h1>CSS border-radius Property</h1> <h2>border-radius: 50px;</h2> <div id="point"> border-radius: 50px; </div> <h2>border-radius: 50%;</h2> <div id="point1"> border-radius: 50%; </div> <h2>border-radius: 50px 10px;</h2> <div id="point2"> border-radius: 50px 10px; </div> <h2>border-radius: 100px 50px 10px;</h2> <div id="point3"> border-radius: 100px 50px 10px; </div> <h2>border-radius: 150px 100px 50px 10px;</h2> <div id="point4"> border-radius: 150px 100px 50px 10px; </div> </body> </html>

Reminder

Hi Developers, we almost covered 98.7% of CSS Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in CSS.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author