Best Division

Spread Your Knowledge

  • All topics
  • About us
  • Contact us
  • Privacy policy
  • Terms of service
  • Copyright
  • Facebook
  • Twitter
  • Instagram
  • Youtube
  • LinkedIn
  • Pinterest
  • Github
  • Tumblr

© 2026 Best Division

How do you create rounded corners with border-radius in CSS?

CSS
Jayant Kumar
Jayant Kumar@jayantkumar314
PublishedDec 3, 2026
5 min read

To create rounded corners in CSS, set the border-radius property on an element, for example border-radius: 8px. The value is the radius of the circle that rounds each corner, and a very large value or 50% on a square turns the box into a circle. This guide covers css border-radius syntax, per-corner values, elliptical corners and common patterns.

Table of Contents

  • Basic border-radius syntax
  • Setting each corner separately
  • Elliptical corners with the slash syntax
  • Rounding images and clipping content
  • How radii interact with borders and shadows
  • A complete example
  • Design tips
  • Frequently Asked Questions
    • How do I make a circle with CSS?
    • How do I round only the top corners?
    • Why are my rounded corners not clipping the image inside?
    • Does border-radius work on tables?
  • Summary
  • Related Articles

Basic border-radius syntax

css

A length such as 8px or 0.5rem gives a fixed radius. A percentage is relative to the box: horizontally to its width and vertically to its height. That is why 50% makes a square a circle but a rectangle an ellipse.

The radius rounds the background and border. It also clips the background image and, with overflow: hidden, the child content.

Setting each corner separately

The shorthand takes one to four values, starting at the top-left and going clockwise.

ValuesMeaning
10pxAll four corners
10px 20pxTop-left and bottom-right 10px, top-right and bottom-left 20px
10px 20px 30pxTop-left 10px, top-right and bottom-left 20px, bottom-right 30px
10px 20px 30px 40pxTop-left, top-right, bottom-right, bottom-left

You can also use longhands.

css

Logical longhands such as border-start-start-radius follow the writing direction, which helps in right-to-left layouts.

Elliptical corners with the slash syntax

Each corner can have a different horizontal and vertical radius. Write horizontal values, a slash, then vertical values.

css

The leaf rounds only the top-left and bottom-right corners with elliptical curves. The blob uses organic percentages to create an irregular shape without any image.

Rounding images and clipping content

css

On an img, border-radius clips the picture itself. On a container, overflow: hidden is needed so child images or colored headers do not poke out of the rounded corners. object-fit: cover stops a non-square photo from being squashed inside a round avatar.

How radii interact with borders and shadows

The curve follows the outer edge of the border, and the inner edge gets a smaller radius automatically (outer radius minus border width, never below zero). box-shadow and outline follow the rounded shape in current browsers, so a card with a shadow keeps soft corners.

If radii on adjacent corners add up to more than the side length, browsers scale all radii down proportionally, so the shape stays valid. This is why 999px makes a clean pill: the radii shrink until they fit exactly half the height.

A complete example

html

Design tips

  • Pick a small set of radii (for example 4, 8 and 16 pixels) and reuse them as custom properties so the interface feels consistent.
  • Nested rounded boxes look best when the inner radius is the outer radius minus the padding between them.
  • Use rem for radii when you want them to scale with user font size settings, or px when you want a fixed look.

Frequently Asked Questions

How do I make a circle with CSS?

Give the element equal width and height and set border-radius: 50%.

How do I round only the top corners?

Set border-top-left-radius and border-top-right-radius, or use the shorthand border-radius: 12px 12px 0 0.

Why are my rounded corners not clipping the image inside?

Add overflow: hidden to the container, or put border-radius directly on the img.

Does border-radius work on tables?

It works on table cells and, with border-collapse: separate, on tables. With border-collapse: collapse the radius does not apply to the table borders.

Summary

border-radius rounds corners with one to four values, longhands for single corners and a slash syntax for elliptical shapes. Use 50% for circles, a large value for pills and overflow: hidden to clip children. Reuse a few consistent radii across the design.

Related Articles

  • How do you set border width, style and color in CSS?
  • How Do You Add Shadows to Elements With CSS box-shadow?
  • Learn CSS: Complete Study Roadmap from Beginner to Advanced
Share

Similar posts

  • How do you set border width, style and color in CSS?
  • How do radial and conic gradients work in CSS?
  • How do you create a linear gradient in CSS?
  • How do background-size, position and repeat work in CSS?
  • How do you set a background color and image in CSS?
  • How does the color-mix() function work in CSS?
  • What are modern CSS color spaces like oklch and lab?
  • How do you add transparency to colors with alpha in CSS?