Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS border-radius Property

Posted in CSS Tutorial
Updated on Sep 04, 2024
By Mari Selvan
πŸ‘οΈ 12 - Views
⏳ 4 mins
πŸ’¬ 1 Comment
CSS border-radius Property

Photo Credit to CodeToFun

πŸ™‹ Introduction

The border-radius property in CSS is used to create rounded corners on elements.

This property allows you to define how much rounding you want on each corner, which can be applied to all corners uniformly or individually. Rounded corners can add a softer, more modern look to your elements, making your design more visually appealing.

πŸ’‘ Syntax

The syntax for the border-radius property is simple and flexible. You can specify one, two, three, or four values to define the rounding of the corners.

Syntax
Copied
Copy To Clipboard
element {
  border-radius: value;
}
  • One value: Applies to all four corners.
  • Two values: The first value applies to the top-left and bottom-right corners, and the second value applies to the top-right and bottom-left corners.
  • Three values: The first value applies to the top-left corner, the second to the top-right and bottom-left corners, and the third to the bottom-right corner.
  • Four values: Each value applies to a different corner in the order: top-left, top-right, bottom-right, and bottom-left.

πŸŽ›οΈ Default Value

The default value of the border-radius property is 0, which means that the element has sharp, right-angled corners.

🏠 Property Values

ValueDescription
LengthYou can specify a length value (e.g., 10px, 5em) to determine the radius.
PercentageYou can use a percentage (e.g., 50%) to create rounded corners relative to the element's size.
ShorthandThe border-radius property can be specified as a single value, two values, three values, or four values to individually control the radius of each corner.

πŸ“„ Example

In this example, we'll create a box with rounded corners using the border-radius property.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS border-radius Example</title>
  <style>
    .rounded-box {
      width: 200px;
      height: 100px;
      background-color: lightblue;
      border-radius: 15px;
    }
  </style>
</head>
<body>
  <h1>Box with Rounded Corners</h1>
  <div class="rounded-box"></div>
</body>
</html>

πŸ–₯️ Browser Compatibility

The border-radius property is supported in all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. It is a widely supported feature and can be used safely in your web projects.

πŸŽ‰ Conclusion

The border-radius property is an essential tool in modern web design, enabling developers to create visually appealing elements with rounded corners.

Whether you’re designing buttons, images, or entire sections, using border-radius can help soften the look of your interface and make your design more inviting. Experiment with different values and combinations to see how this property can enhance the aesthetics of your web pages.

πŸ‘¨β€πŸ’» Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
πŸ‘‹ Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy