border-radius px vs %: Why 50% Skews Buttons and How to Fix It

PublishedToolCSS Border Radius Generator

Contents
  1. px vs. %: How the Rendering Math Differs
  2. Under the Hood: the W3C Corner-Overlap Scaling Formula (f)
  3. CSS border-radius Units and Syntax Compared
  4. 5 Common border-radius Mistakes
  5. A 5-Step Workflow for Perfect Rounded UI
  6. 7 Practical border-radius Tips
  7. Final decision tree: which border-radius value should you use?
  8. Cheat sheet: key CSS border curvature and rendering terms
  9. Frequently Asked Questions

If you write CSS, you've hit this moment: you're building a rounded button and can't decide between border-radius: 50% and border-radius: 9999px (or 16px).

On a square (100×100px) profile photo box, 50% gives you a perfect circle. But apply that same 50% to a wide rectangle (200×50px) button and you get the strange result many of us have seen: an egg-shaped ellipse with crushed ends.

Here's the full breakdown of the math behind the difference, per the CSS W3C spec — px (a fixed circular radius) versus % (independent horizontal and vertical elliptical radii) — plus the browser's corner-overlap reduction algorithm and the two formulas for a perfect pill button.

Key takeaways ① px units (fixed circle): No matter how big the element is, the radius draws a fixed circular arc with the same horizontal and vertical radius, and the browser automatically clamps it once it exceeds half the shorter side. ② % units (relative ellipse): The horizontal radius is calculated from the element's width (W) and the vertical radius from its height (H), each separately — so on a rectangle you get an ellipse. ③ The perfect pill (capsule) formula: To round both ends of a rectangular button into clean semicircles, don't use 50% — use border-radius: 9999px or border-radius: 100rem. ④ With our CSS Border Radius Generator, you can dial in px and % values for all four corners and pull out the live rendering and the CSS code in about a second.

px vs. %: How the Rendering Math Differs

The CSS rendering engine solves a completely different geometry equation depending on the unit you give border-radius:

1. px Units (Circular Arc, Round Curvature)

rx = ry = the entered px value
  • It always draws an arc from a perfect circle, where the horizontal radius (rx) and vertical radius (ry) are equal.
  • On a box that's 200 × 50px, adding border-radius: 20px puts a clean circular curve with a 20px radius on each corner.

2. % Units (Elliptical Arc, Oval Curvature)

rx = W × (Percentage / 100),   ry = H × (Percentage / 100)
  • Square (W = H = 100px):
    • rx = 100 × 0.5 = 50px, ry = 100 × 0.5 = 50px ⇒ a perfect circle
  • Wide rectangle (W = 200px, H = 50px):
    • rx = 200 × 0.5 = 100px, ry = 50 × 0.5 = 25px
    • The horizontal radius is four times longer than the vertical one, so each end gets a squashed rugby-ball shape.
CSS Border Radius Generator

Free · Adjust the four corners and copy clean border-radius CSS in one second


Under the Hood: the W3C Corner-Overlap Scaling Formula (f)

When the combined curvature of two corners exceeds the length of a box side (L), the browser has a built-in algorithm to keep things from breaking. Here's how it works.

1. The formula for the W3C corner-overlap reduction factor (f)

f = min(1, W/rtop-left, x + rtop-right, x, H/rtop-left, y + rbottom-left, y, … )
  • Every radius is multiplied by the reduction ratio f, so each one scales to r′ = r × f.
  • For example, take a button 50px tall with border-radius: 9999px:
    • Vertical sum: 9999 + 9999 = 19,998px
    • Scale factor: f = 50 / 19998 ≈ 0.0025
    • Effective radius: 9999 × 0.0025 = 25px (clamped to exactly 25px, half the 50px height, which gives you a perfect capsule).

CSS border-radius Units and Syntax Compared

Unit / SyntaxGeometryResult on a Rectangle (W ≠ H)Best For
Fixed px (e.g. 8px)Circular arcUniform 8px curve on all four cornersCard components, modals, input boxes
Relative % (e.g. 50%)Elliptical arcSquashed ellipse (egg shape)Square avatar images, round icons
Extreme value 9999pxAuto-clamped semicirclePerfect pill / capsuleCTA action buttons, tag badges
Eight-value slash (H / V)Independent horizontal/vertical ellipsesOrganic, irregular shape (blob)Atmospheric landing page backgrounds, creative UI

5 Common border-radius Mistakes

  1. Declaring border-radius: 50% on a wide rectangular button: the classic mistake that leaves both ends looking like egg-shaped ellipses.
  2. Trying to make a circle with 50% on a rectangular (not square) image: you get an ellipse instead of a circle, and the image looks stretched.
  3. Forgetting overflow: hidden on the parent box: child images or background colors spill out past the rounded corners.
  4. Mismatched border thickness and inner curvature: a gap opens up between the outer border and the inner content (the inner radius is r − border-width).
  5. Mixing up the shorthand order for the four corners: confusing the clockwise rule (Top-Left ➔ Top-Right ➔ Bottom-Right ➔ Bottom-Left).

A 5-Step Workflow for Perfect Rounded UI

  1. Step 1 (check the element's aspect ratio): Figure out whether the component you're building is a 1:1 square or a wide rectangle.
  2. Step 2 (pick the target shape): Choose one: circle, pill, subtle card rounding, or blob.
  3. Step 3 (apply the unit rules):
    • 1:1 square circle ➔ border-radius: 50%
    • Rectangular pill button ➔ border-radius: 9999px (or rounded-full)
    • Modern card UI ➔ border-radius: 12px (or 0.75rem)
  4. Step 4 (match the parent and child borders): If there's a border, set the inner padding element's radius to Outer Radius − Border Width.
  5. Step 5 (copy the CSS from the generator): Use the sliders to fine-tune, then copy the clean code and paste it into your project.

7 Practical border-radius Tips

  1. How Tailwind CSS rounded-full works under the hood: Tailwind's rounded-full class is implemented as border-radius: 9999px;.
  2. Inner curvature formula for nested boxes: Inner Radius = max(0, Outer Radius − Padding) Follow this and the corners of an image inside a card will line up nicely, parallel to the outer corners.
  3. Height-based pill with CSS calc(): border-radius: calc(var(--button-height) / 2);
  4. Leaf shape with the slash (/) syntax: border-radius: 0 100% 0 100% / 0 100% 0 100%;
  5. GPU anti-aliasing tip: If you see faint stair-stepping on rounded corners, add box-shadow: 0 0 1px transparent; to smooth them out with a soft blur.
  6. border-radius animation: On hover, transition: border-radius 0.3s ease smoothly morphs a square into a pill.
  7. Bookmark the CSS Border Radius Generator: See complex four-corner and slash-ellipse syntax right in front of you and pull the code out in one second.

Final decision tree: which border-radius value should you use?

  • Case A (profile avatar, 1:1 square circular icon) ➔ aspect-ratio: 1/1; border-radius: 50%;
  • Case B (login button, search bar, tag badge capsule) ➔ border-radius: 9999px;
  • Case C (dashboard card, modal popup, form input) ➔ border-radius: 8px ~ 16px; (px/rem)
  • Case D (organic, irregular background design) ➔ border-radius: 60% 40% 30% 70% / ... (slash syntax)

Cheat sheet: key CSS border curvature and rendering terms

  • Border Radius: The property that rounds off the outer corners of a CSS box model element.
  • Elliptical Arc: A curved segment of an ellipse where the horizontal radius (rx) and vertical radius (ry) differ.
  • Clamping: A safety mechanism where the browser scales corner curvature down proportionally when the total would exceed the side length.
  • Pill Shape: A capsule-style UI whose left and right ends close in perfect semicircles (r = H/2).

Frequently Asked Questions

Why use border-radius: 9999px on a button instead of 50px?

If the button text gets longer or the padding grows and the height goes up to 120px, a fixed 50px no longer gives you a full pill — you get a rounded rectangle. With 9999px, the browser always fits the radius to half the height automatically, whether the button is 50px or 200px tall, so a perfect capsule is guaranteed every time.

A photo inside a card with rounded corners sticks out as a square. How do I fix that?

Add the overflow: hidden; property to the card's parent element CSS, and the child image or background will be masked (clipped) cleanly to match the parent's rounded corner curvature.

Is the CSS code generated by the CSS Border Radius Generator compatible with all modern browsers?

Yes. It follows the standard CSS3 border-radius syntax, so it renders the same shape in all major modern browsers — Chrome, Safari, Firefox, Edge — and on mobile.

This article was adapted from our Korean original. Read the Korean original

Related articles

  1. box-shadow cut off: fix overflow clipping on CSS cardsFind which ancestor's overflow is clipping your box-shadow, split rounded images from card shadows, and keep room for shadows in horizontal scrollers.
  2. Circular progress bar SVG: how dasharray and dashoffset fill itA circular progress bar is an SVG stroke, not an image. How stroke-dasharray and stroke-dashoffset fill it like a donut, and how to compute both values.
  3. Why clip-path Shapes Distort: Aspect Ratio Fix ExplainedSee why clip-path stars and polygons stretch on non-square elements, how percentage coordinates are calculated, and how to check and fix the aspect ratio.
  4. Color Blindness Simulator: Why Red and Green Blur TogetherWhy red and green look alike to people with color vision deficiency, why color alone shouldn't carry meaning, and how to check your palette.
  5. WCAG Contrast Ratio 4.5:1: Where the Numbers Come FromSee how the WCAG 4.5:1 and 3:1 contrast thresholds are calculated from relative luminance, and why large text gets a lower requirement.
  6. RGB color distance formula: check your color match accuracyLearn how RGB Euclidean distance turns color differences into a 0–100 match score, then practice with a free slider game.

Related tools