How to create CSS3 Rounded Corners?

The CSS3 border-radius property allows you to create rounded corners on any element. This property transforms sharp rectangular corners into smooth, curved edges, giving your web designs a more modern and polished appearance.

Syntax

selector {
    border-radius: value;
}

Possible Values

Value Description
length Set corner radius in px, em, rem, etc. Default is 0.
% Set corner radius as percentage of element's dimensions

Example 1: Basic Rounded Corners

Here's how to create a container with rounded corners compared to a normal container −

<!DOCTYPE html>
<html>
<head>
<style>
    body {
        font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
        padding: 20px;
    }
    .container {
        display: inline-block;
        width: 200px;
        height: 100px;
        text-align: center;
        font-size: 18px;
        padding: 20px;
        margin: 10px;
        border: 3px solid #4CAF50;
        background-color: #f9f9f9;
    }
    .rounded {
        border-radius: 24px;
    }
    .normal {
        border-radius: 0px;
    }
</style>
</head>
<body>
    <h1>CSS3 Rounded Corner Example</h1>
    <div class="container rounded">Rounded Corners</div>
    <div class="container normal">Default Corners</div>
</body>
</html>
Two boxes appear side by side: one with smooth rounded corners (24px radius) and another with sharp default corners. Both have green borders and light gray backgrounds.

Example 2: Rounded Corners for Images

The border-radius property can also be applied to images to create rounded image containers −

<!DOCTYPE html>
<html>
<head>
<style>
    .image-container {
        width: 150px;
        height: 150px;
        background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
        border-radius: 30px;
        margin: 20px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: white;
        font-weight: bold;
    }
    .circular {
        border-radius: 50%;
    }
</style>
</head>
<body>
    <h1>Rounded Image Containers</h1>
    <div class="image-container">Rounded</div>
    <div class="image-container circular">Circular</div>
</body>
</html>
Two gradient boxes appear: one with rounded corners (30px radius) and another that's perfectly circular (50% radius). Both display centered white text.

Key Points

  • Use a single value for uniform rounding on all corners
  • Use border-radius: 50% to create perfect circles
  • Different values can be applied to individual corners using shorthand
  • Works with borders, backgrounds, and images

Conclusion

The border-radius property is essential for modern web design, allowing you to create smooth, rounded corners easily. Use pixel values for consistent sizing or percentages for responsive, proportional rounding.

Updated on: 2026-03-15T15:07:08+05:30

200 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements