Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS border-top-right-radius Property

Posted in CSS Tutorial
Updated on Aug 08, 2024
By Mari Selvan
👁️ 12 - Views
⏳ 4 mins
💬 1 Comment
CSS border-top-right-radius Property

Photo Credit to CodeToFun

🙋 Introduction

The border-top-right-radius property in CSS is used to round the top-right corner of an element's border.

This property allows you to create visually appealing elements by applying a curved edge to the top-right corner of elements like buttons, boxes, or images. The radius of the curve can be adjusted to achieve various styles, ranging from subtle rounding to a full circle.

💡 Syntax

The syntax for the border-top-right-radius property is simple and flexible. You can specify the radius using different units such as pixels (px), percentages (%), or em units.

Syntax
Copied
Copy To Clipboard
element {
  border-top-right-radius: value;
}
  • value: Specifies the radius of the top-right corner. It can be a length (e.g., 10px) or a percentage (e.g., 50%).

🎛️ Default Value

The default value of the border-top-right-radius property is 0. This means that by default, there is no rounding applied to the top-right corner of an element.

🏠 Property Values

ValueDescription
lengthA length value, such as 10px or 1em, that defines the radius of the corner.
percentageA percentage value, such as 50%, which defines the radius relative to the element's width or height.
initialSets the property to its default value (0).
inheritInherits the border-top-right-radius value from its parent element.

📄 Example

In this example, we'll apply a border-top-right-radius to a box element, rounding the top-right corner by 20 pixels.

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-top-right-radius Example</title>
  <style>
    .box {
      width: 200px;
      height: 100px;
      background-color: lightblue;
      border: 2px solid blue;
      border-top-right-radius: 20px;
    }
  </style>
</head>
<body>
  <h1>Box with Rounded Top-Right Corner</h1>
  <div class="box"></div>
</body>
</html>

🖥️ Browser Compatibility

The border-top-right-radius property is widely supported across all modern browsers, including Chrome, Firefox, Safari, Edge, and Opera. As with any CSS property, it is advisable to test your design across different browsers to ensure consistent rendering.

🎉 Conclusion

The border-top-right-radius property is a useful tool for adding subtle or pronounced rounding to the top-right corner of an element's border.

Whether you're designing buttons, containers, or other UI elements, this property allows you to enhance the visual appeal of your designs with ease. Experiment with different radius values to find the perfect fit for your web projects.

👨‍💻 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