What You'll Learn
Rounded corners have become a defining characteristic of modern web design, softening visual hierarchy and creating more approachable interfaces. Whether you're building simple cards or complex UI systems, these CSS techniques will help you create polished, performant interfaces. Our web development approach emphasizes clean, maintainable code that scales with your needs.
This guide covers:
- border-radius fundamentals -- from basic syntax to advanced elliptical corners
- Individual corner control -- longhand properties for precise styling
- The corner-shape property -- advanced geometries like squircles, bevels, and notches
- Performance considerations -- keeping your site fast while using rounded styles
- Best practices -- creating cohesive component systems
Understanding the key properties for rounded corner implementation
border-radius Property
The foundational CSS property for creating rounded corners with support for all modern browsers and flexible value types.
Longhand Properties
Individual corner control with border-top-left-radius and similar properties for precise styling.
Elliptical Corners
The slash notation enables non-circular curves for pill shapes and elongated elements.
corner-shape Property
Experimental feature for advanced geometries including bevels, notches, and squircles.
Understanding the border-radius Property
The border-radius property represents one of CSS's most widely-adopted features for creating rounded corners. When applied to any block-level element, it defines the curvature of the box's corners, transforming sharp edges into smooth curves.
The property accepts length values (px, em, rem, %, vw) that specify the radius of the quarter ellipse used to round each corner. The shorthand follows a consistent clockwise pattern starting from the top-left corner. This consistency makes it intuitive for developers familiar with other CSS shorthand properties like margin and padding.
When you apply border-radius to an element, the rounded shape affects not only the element's border but also its background, background images, and box-shadow effects. This comprehensive behavior makes border-radius particularly useful for creating cohesive visual components where all visual layers share the same corner treatment.
Single Value Application
Applying a single value to border-radius creates uniform rounding across all four corners of an element. This approach works well for buttons, cards, avatar images, and any UI element that benefits from consistent, symmetrical corner treatment. The simplicity of this syntax makes it the most common approach for basic rounded corner requirements.
For example, setting border-radius: 8px on a button element creates subtle, professional-looking rounding that enhances the button's visual appeal without distracting from its primary action. Single-value applications also prove ideal for circular elements, where you set border-radius to 50% of the element's smallest dimension to transform square images into perfect circles.
Two, Three, and Four Value Syntaxes
The border-radius property supports multiple value specifications that enable asymmetric corner rounding when design requirements call for more sophisticated visual treatments. The syntax follows a clockwise pattern starting from the top-left corner, allowing precise control over each individual corner's curvature.
When two values are provided, the first value applies to the top-left and bottom-right corners while the second value handles the top-right and bottom-left corners. This pattern proves useful for creating subtle directional emphasis in design elements or achieving specific visual balances that uniform rounding cannot provide.
Three-value specifications apply the first value to the top-left corner, the second to both top-right and bottom-left corners, and the third to the bottom-right corner. Four-value specifications provide complete control, applying values sequentially to the top-left, top-right, bottom-right, and bottom-left corners in clockwise order.
Using the Slash Notation
The slash notation in border-radius enables creation of elliptical corners rather than circular ones, allowing separate horizontal and vertical radius values for each corner. This powerful syntax unlocks dramatic visual possibilities, from subtle stretching effects to dramatic elongated curves.
Without the slash, border-radius creates circular corners where the horizontal and vertical radii are equal. Adding a slash introduces elliptical geometry, where the values before the slash define horizontal radii and values after the slash define vertical radii. For example, border-radius: 20px / 10px creates corners that are twice as wide as they are tall. This elliptical capability proves particularly valuable for creating pill-shaped buttons, elongated badge elements, and sophisticated UI components that benefit from non-circular corner treatments.
1/* Single value - uniform rounding */2.card {3 border-radius: 12px;4}5 6/* Two values - TL/BR and TR/BL */7.asymmetric {8 border-radius: 8px 16px;9}10 11/* Three values - TL, TR+BL, BR */12.complex {13 border-radius: 4px 12px 20px;14}15 16/* Four values - clockwise from TL */17.full-control {18 border-radius: 4px 8px 12px 16px;19}20 21/* Elliptical corners with slash */22.pill-button {23 border-radius: 9999px;24 padding: 8px 24px;25}26 27/* Different horizontal/vertical */28.elliptical {29 border-radius: 20px / 10px;30}Controlling Individual Corners
For scenarios requiring precise control over specific corners, CSS provides four longhand properties: border-top-left-radius, border-top-right-radius, border-bottom-right-radius, and border-bottom-left-radius. These offer granular control without requiring developers to calculate clockwise positions.
Each longhand property accepts the same value types as the shorthand, including length values, percentages, and the elliptical slash notation. This consistency means developers can freely mix shorthand and longhand declarations based on which approach provides the clearest expression of their intent. Understanding CSS selectors helps when combining these properties with other styling techniques.
When to Use Longhand Properties
Longhand properties prove valuable in component-based architectures where different elements within a component might require different corner treatments. Rather than overriding a shorthand declaration with multiple cascade-breaking rules, developers can use longhand properties to modify only the corners that need adjustment while inheriting the base treatment from a shared class. This approach aligns with modern component-based web development practices.
Longhand Syntax Examples
/* Target top-left corner only */
.leaf-element {
border-top-left-radius: 16px;
}
/* Bottom-right emphasis */
.special-card {
border-bottom-right-radius: 24px;
}
/* Combining corners for custom shapes */
.custom-badge {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom-left-radius: 0;
border-bottom-right-radius: 0;
}
/* Longhand with elliptical values */
.elliptical-corner {
border-top-left-radius: 20px / 8px;
}
The ability to target individual corners independently also enables creative effects like stair-step borders, custom tab shapes, and intricate geometric patterns that would be difficult or impossible to achieve with shorthand declarations alone.
The Modern corner-shape Property
The corner-shape property represents CSS's evolution beyond simple circular rounding, introducing the ability to create sophisticated corner geometries including bevels, notches, squircles, and scoops. Currently experimental with limited browser support, corner-shape works in conjunction with border-radius to define the actual shape applied within the rounded area.
Unlike border-radius which only creates circular or elliptical arcs, corner-shape accepts various shape keywords and the superellipse() function that mathematically describes a broader range of curves. The property can be specified once for all corners or individually for each corner.
The default value is round, producing the same effect as traditional border-radius. Additional keywords include square for sharp corners, bevel for angled cuts, notch for V-shapes, squircle for superellipse shapes, and scoop for inward-curving scoops.
Shape Keywords
| Keyword | Effect |
|---|---|
round | Default circular arc |
square | Sharp corners |
bevel | Angular cuts |
notch | Inward V-shape |
squircle | Superellipse curve |
scoop | Inward scoop |
The superellipse() Function
The superellipse() function provides mathematical control over corner curvature, accepting a numeric parameter that defines the shape's characteristics. This function enables both predefined keyword shapes and infinitely adjustable variations between them, giving designers precise control over corner geometry.
Positive parameter values produce outward-curving shapes similar to traditional rounding, while negative values create inward-pointing geometries like notches and scoops. The magnitude of the parameter determines how dramatically the shape deviates from a pure circle, with higher absolute values producing more extreme effects. This relationship enables designers to smoothly animate between different corner shapes by transitioning the superellipse parameter.
Browser Support
The corner-shape property currently has limited browser support, working in Chrome and Edge but not yet in Firefox or Safari. According to MDN's Baseline indicator, the feature has "Limited availability" due to restricted browser support.
Developers should implement progressive enhancement strategies, using corner-shape as an enhancement rather than a core requirement. This includes providing fallback border-radius styles for unsupported browsers, using feature detection to apply corner-shape only when supported, and communicating the experimental nature of the feature to project stakeholders.
1/* Basic rounded corners (default) */2.standard {3 border-radius: 16px;4 corner-shape: round;5}6 7/* Sharp corners */8.sharp {9 border-radius: 16px;10 corner-shape: square;11}12 13/* Beveled corners */14.beveled {15 border-radius: 24px;16 corner-shape: bevel;17}18 19/* Notched corners */20.notched {21 border-radius: 32px;22 corner-shape: notch;23}24 25/* Squircles */26.squircle {27 border-radius: 24px;28 corner-shape: squircle;29}30 31/* Scooped corners */32.scooped {33 border-radius: 24px;34 corner-shape: scoop;35}36 37/* Custom superellipse */38.custom-shape {39 border-radius: 24px;40 corner-shape: superellipse(0.6);41}42 43/* Mixed corner shapes */44.mixed {45 border-radius: 24px;46 corner-shape: notch scoop bevel round;47}Performance Considerations
While border-radius has no significant performance impact for typical usage, understanding how browsers render rounded corners helps developers make informed decisions about complex implementations. The property triggers rendering calculations involving path clipping and compositing operations, but modern browsers handle these efficiently for common use cases.
Animation Performance
Performance considerations become more relevant when animating border-radius values or applying corner-shape effects to large numbers of elements simultaneously. In such scenarios, developers should test animations on target devices to ensure smooth 60fps rendering, potentially reducing animation complexity or using CSS transforms as alternatives.
Optimization Strategies
For optimal performance with rounded corners, consider these strategies. Avoid animating border-radius on elements that occupy large viewport areas, as this triggers more extensive repaints. When animating corner shapes, prefer transitioning between similar values rather than dramatic changes. Use CSS will-change sparingly and only when profiling identifies actual performance bottlenecks.
Testing on target devices ensures that animations perform as expected across the hardware your users actually have. Lower-end mobile devices may struggle with complex corner-shape animations that work smoothly on desktop machines.
corner-shape Performance
The corner-shape property may involve more complex calculations than traditional border-radius due to its support for non-circular geometries. As noted in MDN's documentation, testing corner-shape implementations across different devices helps identify any performance implications specific to your target audience's hardware. Consider providing simpler fallback styles for browsers that support corner-shape but may struggle with complex animations.
For teams building performance-critical applications, our web development services include comprehensive performance optimization to ensure smooth animations across all devices.
Best Practices for Rounded Corner Implementation
Implementing rounded corners effectively requires attention to consistency, accessibility, and maintainability. Design systems benefit from establishing clear conventions for corner radius values, ensuring related components share appropriate visual relationships.
Consistency in Design Systems
Consistent radius values across a design system create visual harmony and reduce cognitive load for users. Establishing a scale of approved radius values--perhaps 4px, 8px, 12px, and 16px--provides sufficient variety for different component types while maintaining system-wide consistency.
Accessibility Considerations
Accessibility considerations include ensuring sufficient color contrast at curved border edges and avoiding corner radii so large that important content becomes obscured or difficult to interact with. Testing rounded components with screen readers and keyboard navigation confirms that visual rounding does not impair functional accessibility.
Responsive Scaling
Responsive design often requires scaling rounded corners proportionally to viewport size. Using viewport units like vw or vh directly in border-radius declarations creates fluid scaling tied to viewport dimensions. Combining these with CSS clamp() functions establishes minimum and maximum bounds that prevent extreme values while allowing proportional adjustment.
Percentage-based border-radius values scale automatically with element dimensions, creating consistent proportions regardless of container size. This approach works particularly well for components like cards that might appear at various sizes across different page layouts. For more advanced responsive techniques, explore our guide on CSS Grid transitions.
Component System Design
Design systems benefit from establishing hierarchical relationships between component corner radii. Primary actions might use smaller, more subtle rounding while secondary elements use larger values that visually recede. This hierarchy guides user attention through consistent visual language.
Component libraries often define radius tokens that map semantic meanings to specific pixel values. These tokens can then be referenced throughout the stylesheet, enabling global adjustments by modifying token values rather than hunting through individual component styles. Testing component relationships at various viewport sizes ensures that the radius hierarchy remains apparent across different display contexts.
Practical Code Examples
These examples demonstrate how to apply rounded corner techniques to real-world scenarios, covering the most common implementation patterns.
Circular Avatar
Creating circular avatars requires setting border-radius to 50% of the element's smallest dimension. Combined with object-fit: cover for images, this technique ensures properly cropped circular profile pictures regardless of original image dimensions. This pattern appears throughout modern web applications for user avatars, profile pictures, and circular icon badges.
Pill-Shaped Buttons
Pill-shaped buttons use elliptical border-radius with horizontal values larger than half the element's height, creating the distinctive capsule shape. Setting border-radius to values larger than half the element's height produces the pill effect, as seen in the code example below. This button style has become ubiquitous in modern interface design due to its friendly, approachable appearance.
Card Components
Card components typically use moderate border-radius values between 8px and 16px that provide visual softening without overwhelming the content. Values in this range work well for most card designs, with larger cards potentially benefiting from proportionally larger values. Combining border-radius with subtle box-shadow creates depth while maintaining clean visual lines.
Asymmetric Corner Treatments
When specific corners require different treatment, the multi-value syntax or longhand properties provide the necessary control. This technique appears in navigation elements, custom tab designs, and creative promotional components where directional visual cues guide user attention.
1/* Circular avatar images */2.avatar {3 width: 48px;4 height: 48px;5 border-radius: 50%;6 object-fit: cover;7}8 9/* Pill-shaped buttons */10.button-pill {11 border-radius: 9999px;12 padding: 8px 24px;13}14 15/* Card components */16.card {17 border-radius: 12px;18 background: white;19 box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);20}21 22/* Asymmetric corners */23.asymmetric {24 border-radius: 4px 16px 4px 16px;25}26 27/* Responsive scaling */28.responsive {29 border-radius: clamp(4px, 2vw, 16px);30}31 32/* Elliptical button */33.elliptical-button {34 border-radius: 20px / 10px;35 padding: 12px 32px;36}Frequently Asked Questions
Does border-radius affect borders?
Yes, border-radius affects the element's border, background, background images, and box-shadow effects. All these visual layers follow the corner curvature defined by the property.
Can I animate border-radius values?
Yes, border-radius values can be animated smoothly. However, animating between significantly different values or many elements simultaneously may impact performance on lower-end devices.
What is the difference between border-radius and corner-shape?
border-radius creates circular or elliptical arcs for rounding corners. corner-shape (experimental) defines the actual geometry within the rounded area, enabling shapes like bevels, notches, and squircles.
How do I make a perfect circle?
Set border-radius to 50% of the element's smallest dimension. For images, combine with object-fit: cover to ensure proper cropping within the circular container.
What browsers support corner-shape?
corner-shape currently has limited support, working in Chrome and Edge but not yet in Firefox or Safari. Use feature detection and progressive enhancement when implementing.
Conclusion
Mastering rounded corners in CSS spans from the foundational border-radius property to the experimental corner-shape feature that opens new design possibilities. Understanding the syntax options, performance implications, and best practices enables developers to create polished, performant interfaces that meet modern design standards.
The border-radius property remains the reliable workhorse for most rounding requirements, with comprehensive browser support and intuitive syntax. As corner-shape gains browser support, developers will gain access to sophisticated corner geometries that expand the visual vocabulary of web design.
Key Takeaways:
- Use border-radius for all standard rounded corner requirements
- Leverage longhand properties for individual corner control
- Explore corner-shape for advanced geometries when browser support allows
- Test performance on target devices, especially for animations
- Establish design system conventions for consistent radius scaling
Looking to implement modern CSS techniques in your next project? Our web development team specializes in building polished, performant websites using the latest frontend technologies and best practices.