How to create a CSS3 property for each corner?

CSS3 provides several methods to create custom corner styles for elements. This allows designers to move beyond simple rectangular shapes and create more visually appealing interfaces with unique corner treatments.

Syntax

/* Method 1: Border-radius */
border-radius: top-left top-right bottom-right bottom-left;

/* Method 2: Individual corner properties */
border-top-left-radius: value;
border-top-right-radius: value;
border-bottom-right-radius: value;
border-bottom-left-radius: value;

/* Method 3: Clip-path */
clip-path: polygon(x1 y1, x2 y2, x3 y3, x4 y4);

/* Method 4: Mask-image */
mask-image: gradient-function;

Method 1: Using Border-radius Property

The border-radius property allows you to specify different radius values for each corner in a single declaration. The values are applied clockwise starting from the top-left corner.

<!DOCTYPE html>
<html>
<head>
<style>
    .box {
        width: 200px;
        height: 200px;
        background-color: #4CAF50;
        border-radius: 10px 20px 30px 40px;
        margin: 20px;
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
A green box with different corner radii: 10px top-left, 20px top-right, 30px bottom-right, 40px bottom-left.

Method 2: Using Individual Corner Properties

This approach uses separate properties for each corner, providing more explicit control and better readability when different corners need specific treatments.

<!DOCTYPE html>
<html>
<head>
<style>
    .box {
        width: 200px;
        height: 200px;
        background-color: #2196F3;
        border-top-left-radius: 50px;
        border-top-right-radius: 10px;
        border-bottom-right-radius: 50px;
        border-bottom-left-radius: 10px;
        margin: 20px;
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
A blue box with alternating corner radii creating an oval-like shape with 50px radius on opposite corners and 10px on the others.

Method 3: Using Clip-path Property

The clip-path property creates custom shapes by defining a clipping region. This method offers unlimited creative possibilities for corner designs.

<!DOCTYPE html>
<html>
<head>
<style>
    .box {
        width: 200px;
        height: 200px;
        background-color: #FF9800;
        clip-path: polygon(20% 0%, 100% 0%, 80% 100%, 0% 100%);
        margin: 20px;
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
An orange parallelogram-shaped box with angled corners created by the polygon clipping path.

Method 4: Using Mask-image Property

The mask-image property uses gradients or images to selectively hide parts of an element, creating unique corner effects through masking.

<!DOCTYPE html>
<html>
<head>
<style>
    .box {
        width: 200px;
        height: 200px;
        background-color: #9C27B0;
        mask-image: radial-gradient(circle at top left, transparent 30px, black 30px);
        -webkit-mask-image: radial-gradient(circle at top left, transparent 30px, black 30px);
        margin: 20px;
    }
</style>
</head>
<body>
    <div class="box"></div>
</body>
</html>
A purple box with a circular cutout in the top-left corner, created by the radial gradient mask.

Conclusion

CSS3 offers multiple approaches for creating custom corner effects. Use border-radius for simple rounded corners, individual corner properties for precise control, clip-path for complex geometric shapes, and mask-image for creative masking effects.

Updated on: 2026-03-15T17:57:37+05:30

218 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements