The Modern Guide to Making CSS Shapes

Create triangles, hexagons, stars, and organic shapes using modern CSS properties like clip-path, border-radius, and the new corner-shape feature.

Understanding CSS Shape Fundamentals

Creating shapes with CSS has evolved significantly from the early days of border hacks and magic numbers. Modern CSS provides clean, performant properties for creating everything from simple geometric forms to complex organic shapes.

The Evolution of CSS Shapes

In the early days of web design, creating a simple triangle required transparent borders and creative use of the border property--a technique that worked but felt like a hack. Today's CSS offers purpose-built properties that make shape creation intuitive and maintainable.

When to Use CSS Shapes

CSS shapes excel in several scenarios. Use CSS shapes for decorative elements that need to scale across viewports without pixelation, UI components like badges, tooltips, and notification indicators, and interactive elements that animate or transition between states. For complex illustrations, icons requiring precise scaling, or text wrapping around irregular forms, SVG and the CSS Shapes module (with shape-outside) remain better choices.

The key advantage of CSS shapes is their seamless integration with the styling system--shapes inherit colors, respond to hover states, and animate with the same CSS transitions you already use throughout your web development projects.

The Three Pillars of CSS Shapes

Three main approaches for creating shapes in modern CSS

clip-path

Polygon-based clipping for complex geometric shapes using polygon(), circle(), ellipse(), and inset() functions.

border-radius

Rounded corners and organic shapes with the powerful 8-value syntax for elliptical and blob-like forms.

corner-shape

The new 2024-2025 CSS feature for creating notches, bevels, and scoops on corners without complex polygons.

Creating Geometric Shapes with clip-path

The CSS clip-path property is your primary tool for creating polygons and complex shapes. The polygon() function accepts coordinate pairs that define the vertices of your shape.

The Key Insight: Use Points Outside the Box

A powerful technique for simplifying shape definitions is to use coordinates outside the [0% 100%] range. This "thinking outside the box" approach lets you create complex shapes with fewer points by leveraging the natural geometry of the coordinate system.

Creating Triangles with clip-path
1/* Triangle using clip-path */2.triangle {3 width: 200px;4 aspect-ratio: 0.866;5 clip-path: polygon(50% 0%, 0% 100%, 100% 100%);6}7 8/* Down-pointing triangle */9.triangle-down {10 clip-path: polygon(0% 0%, 100% 0%, 50% 100%);11}

Hexagons: The Four-Point Trick

Most developers use 6 points for hexagons, but with the outside-the-box technique, you only need 4. By placing two points at negative x-coordinates and two at positions beyond 100%, the natural geometry of the shape emerges automatically. Combined with aspect-ratio: cos(30deg) (approximately 0.866), you get perfect hexagon proportions without calculating individual vertex positions.

Efficient Hexagon Using 4 Points
1/* Hexagon with only 4 points */2.hexagon {3 width: 200px;4 aspect-ratio: cos(30deg);5 clip-path: polygon(6 -50% 50%,7 50% 100%,8 150% 50%,9 50% 010 );11}

Octagons and Complex Polygons

Building on the hexagon technique, you can create 8-point octagons--the classic stop sign shape--by defining points at both the corners and the midpoint positions along each edge. The coordinates follow a predictable pattern: start at 30% on each edge, move to corners, then repeat for the opposite side. This same logic extends to any polygon: identify the natural vertices and edge midpoints, then define points that trace the perimeter efficiently.

Stars: Point-by-Point Creation

Creating star shapes requires calculating both outer points (the star points) and inner points (where the arms connect). The key is alternating between an outer radius and a smaller inner radius. For a standard five-pointed star, you work around a circle, moving 72 degrees between each point (360° ÷ 5). Outer points sit at the full radius, while inner points sit at approximately 38% of that radius. This creates the classic star proportions with sharp, defined points.

Five-Pointed Star with clip-path
1/* Five-pointed star */2.star {3 width: 200px;4 aspect-ratio: 1;5 clip-path: polygon(6 50% 0%,7 61% 35%,8 98% 35%,9 68% 57%,10 79% 91%,11 50% 70%,12 21% 91%,13 32% 57%,14 2% 35%,15 39% 35%16 );17}

Rounded Shapes with border-radius

Beyond simple rounded corners, border-radius offers powerful capabilities for creating organic, blob-like shapes with its 8-value syntax.

Advanced border-radius Syntax

The slash notation in border-radius allows you to specify different horizontal and vertical radii. The format border-radius: h1 v1, h2 v2, ... controls each corner independently. When you include a slash, the values before it set horizontal radii and values after it set vertical radii. This means border-radius: 30% 70% 70% 30% / 30% 30% 70% 70% creates a shape with four different corner curvatures, each potentially elliptical. This 8-value pattern is the secret to creating organic, blob-like shapes that feel natural and flowing rather than geometrically perfect.

Organic Blob Shape with Animated border-radius
1/* Organic blob shape */2.blob {3 width: 200px;4 aspect-ratio: 1;5 border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%;6 animation: blob-morph 4s ease-in-out infinite;7}8 9@keyframes blob-morph {10 0%, 100% { border-radius: 30% 70% 70% 30% / 30% 30% 70% 70%; }11 33% { border-radius: 70% 30% 30% 70% / 70% 70% 30% 30%; }12 66% { border-radius: 100% 60% 60% 100% / 100% 100% 60% 60%; }13}

The New CSS corner-shape Property (2024-2025)

The corner-shape property is a modern CSS feature that enables creating fancy corner effects without complex clip-path coordinates. It works with corner-size to control the magnitude of the corner effect.

Supported Corner Shapes

  • bevel: Creates a 45-degree angled corner cut
  • notch: Creates an inward rectangular cut
  • scoop: Creates an inward curved scoop
  • round: Similar to border-radius (for parity)
  • clip: Sharp corner (default)

You can apply different shapes to each corner by listing multiple values: corner-shape: notch bevel scoop round applies each shape to successive corners starting from the top-left. This approach aligns with modern UI/UX design trends that favor unique corner treatments over standard rounded rectangles.

corner-shape Property Examples
1/* Notched corner for notifications */2.notification {3 corner-shape: notch;4 corner-size: 16px;5}6 7/* Beveled corner card */8.bevel-card {9 corner-shape: bevel;10 corner-size: 12px;11}12 13/* Scoop corner for buttons */14.scoop-button {15 corner-shape: scoop;16 corner-size: 8px;17}18 19/* Individual corners */20.mixed-corners {21 corner-shape: notch bevel scoop round;22 corner-size: 10px;23}

Practical Code Snippets Library

Geometric Shapes

Here are ready-to-use CSS snippets for common geometric shapes. Copy these into your projects and customize the width and colors to match your design system. These snippets form the foundation of any modern front-end development toolkit.

Geometric Shape Snippets
1/* Diamond */2.diamond {3 clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);4}5 6/* Pentagon */7.pentagon {8 clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);9}10 11/* Octagon (stop sign shape) */12.octagon {13 clip-path: polygon(14 30% 0%, 70% 0%,15 100% 30%, 100% 70%,16 70% 100%, 30% 100%,17 0% 70%, 0% 30%18 );19}20 21/* Parallelogram */22.parallelogram {23 clip-path: polygon(25% 0%, 100% 0%, 75% 100%, 0% 100%);24}

UI Component Shapes

These shapes are designed specifically for UI patterns like speech bubbles, tags, badges, and decorative dividers. The corner-shape examples leverage the modern CSS feature for clean, performant corner effects.

UI Component Shape Snippets
1/* Speech bubble */2.speech-bubble {3 position: relative;4 clip-path: polygon(5 0% 0%, 100% 0%,6 100% 75%, 75% 75%,7 75% 100%, 50% 75%,8 0% 75%9 );10}11 12/* Tag/badge with notch */13.tag {14 corner-shape: notch;15 corner-size: 12px;16 padding-right: 24px;17}18 19/* Section divider */20.wavy-divider {21 clip-path: polygon(22 0% 100%, 0% 20%,23 10% 35%, 20% 20%,24 30% 35%, 40% 20%,25 50% 35%, 60% 20%,26 70% 35%, 80% 20%,27 90% 35%, 100% 20%,28 100% 100%29 );30}

Performance and Best Practices

Performance Considerations

  • clip-path is generally more performant than mask-image for simple shapes because it creates a true clipping region that the browser can optimize
  • Use will-change: transform for animated shapes to trigger GPU acceleration, but apply it judiciously to avoid memory overhead
  • Avoid animating complex clip-path coordinates between shapes with vastly different point counts; instead, toggle between predefined shapes with consistent point counts
  • Test performance on target devices, especially for mobile--complex polygons can impact rendering performance on lower-end devices

Browser Compatibility

  • clip-path: Well-supported across modern browsers including Chrome, Firefox, Safari, and Edge. Use -webkit- prefix for broader Safari support
  • border-radius: Universal support across all browsers
  • corner-shape: Currently available in Chrome 2025+ with other browsers following. Use @supports (corner-shape: notch) for progressive enhancement

Progressive Enhancement

When using cutting-edge CSS shape features, implement fallbacks that maintain functionality. For corner-shape, a standard border-radius or simple square corners provide acceptable alternatives. Use feature queries to apply enhanced styles only when supported:

.card {
 /* Fallback for older browsers */
 border-radius: 8px;
}

@supports (corner-shape: bevel) {
 .card {
 corner-shape: bevel;
 corner-size: 12px;
 border-radius: 0;
 }
}

Accessibility

  • Ensure shape clipping doesn't obscure important content or interactive elements
  • Don't remove focus indicators on shaped buttons--provide alternative focus styles if needed
  • Respect prefers-reduced-motion for shape animations to accommodate users with vestibular disorders

For comprehensive SEO optimization, ensure that clipped content remains accessible to search engines and screen readers.

Frequently Asked Questions

Ready to Build Custom Web Experiences?

Our team creates stunning websites with modern CSS techniques that load fast and look great on every device.