Color scheme

Shape Outside

Grid and flexbox handle page layout. Float handles text wrapping. That division of labor is important because shape-outside only works on floated elements. It tells the browser to wrap inline content around a shape (a circle, a polygon, or the alpha channel of an image) instead of wrapping around the element's rectangular box. The result is the kind of magazine-style text flow where words curve around a circular photo or follow the contour of an illustration, something no grid or flexbox property can produce.

This is one of the rare cases in modern CSS where float is still the right tool. You are not using it for layout. You are using it for what it was originally designed to do: let inline content flow around an element. shape-outside just makes that flow follow a more interesting path than a rectangle.

When Float Still Earns Its Keep

The advice to "stop using floats for layout" is correct but incomplete. Floats are no longer the right tool for placing columns, sidebars, or card grids. Grid and flexbox do that work better in every way. But floats remain the only mechanism in CSS that makes inline content reflow around an embedded element. If you want a paragraph of text to wrap around a circular image, you need float. There is no grid or flexbox equivalent.

The key distinction is layout versus flow. Layout means placing blocks on a page. Flow means controlling how inline content (text, inline images, spans) distributes itself around an obstacle. shape-outside operates entirely in the flow domain. It modifies the shape of the float area that inline content wraps around, and it has no effect on elements that are not floated.

Shape Functions

The shape-outside property accepts the same shape functions as clip-path: circle(), ellipse(), inset(), and polygon(). The difference is what they control. On clip-path, the shape determines what is visible. On shape-outside, the shape determines where text is allowed to flow.


        /* Circular text wrap around a floated image */
        .profile-photo {
            float: left;
            width: 200px;
            height: 200px;
            border-radius: 50%;
            shape-outside: circle(50%);
            margin-right: 1.5rem;
            margin-bottom: 0.5rem;
        }
    

Without shape-outside, the text wraps around the image's rectangular box even though border-radius makes it look circular. The text hugs the invisible corners of the rectangle. Adding shape-outside: circle(50%) tells the browser that the float area is actually a circle, so text flows along the curved edge instead. Pair it with clip-path: circle(50%) if you want the image itself clipped to the same shape.


        /* Polygon: text wraps around a diagonal edge */
        .pull-quote {
            float: right;
            width: 45%;
            shape-outside: polygon(20% 0%, 100% 0%, 100% 100%, 0% 100%);
            padding: 1rem 0 1rem 2rem;
        }
    

The polygon above defines a shape with an angled left edge. Text flows along that diagonal rather than hitting a flat vertical wall. This creates the kind of pull-quote treatment you see in editorial magazine layouts where text tapers around a callout block.

Image-Based Shapes

Beyond geometric functions, shape-outside can derive its shape from the alpha channel of an image. If you float a transparent PNG, the browser can trace the visible pixels and wrap text around the actual content rather than the bounding box:


        .cutout {
            float: left;
            width: 300px;
            shape-outside: url('/images/cutout.png');
            shape-image-threshold: 0.5;
            shape-margin: 1rem;
        }
    

shape-image-threshold controls how transparent a pixel must be before text is allowed to occupy that space. A value of 0.5 means any pixel more than 50% opaque is treated as part of the shape. shape-margin adds breathing room between the shape edge and the flowing text, which prevents words from pressing uncomfortably tight against the image contour.

Image-based shapes are the most visually dramatic use of shape-outside because the text follows organic, irregular contours. However, they require careful image preparation. The PNG must have clean alpha edges, and the image must be served from the same origin or with appropriate CORS headers, because the browser needs to read the pixel data to compute the shape.

Contrast with Grid-First Editorials

A common question is why you would use shape-outside when you can create editorial layouts with CSS Grid. The answer is that they solve different problems. Grid places elements in cells. shape-outside makes text flow around elements in a non-rectangular path. You can combine them: use grid to position your major content blocks (article, sidebar, images), and then use shape-outside on a floated element within one of those grid cells to create magazine-style text wrapping inside that cell.

The trade-off is control versus fluidity. Grid gives you precise, predictable placement. shape-outside gives you organic, content-dependent flow that changes as the text length, font size, or container width changes. That responsiveness is both its strength and its challenge.

Responsive Reflow

shape-outside reflows text dynamically as the container resizes, which is exactly what you want for responsive design. But it can also cause problems at narrow widths. A floated element with shape-outside: circle(50%) might leave only a sliver of space for text beside it on a small screen, forcing awkward one-word lines.

The fix is to disable the float at a breakpoint where the layout no longer has room for side-by-side flow:


        .profile-photo {
            float: left;
            shape-outside: circle(50%);
            margin-right: 1.5rem;
        }

        @media (max-width: 500px) {
            .profile-photo {
                float: none;
                shape-outside: none;
                margin: 0 auto 1rem;
                display: block;
            }
        }
    

At narrow widths, the image stacks above the text instead of floating beside it. This is a practical pattern you will need in any real-world use of shape-outside. Always test your text wrapping at every viewport width, not just the one where it looks best.

The shape-margin property respects relative units, so shape-margin: 1em scales with the surrounding text size. This keeps the gap between the shape edge and the text proportional even when the font size changes.

Guided Demo

This demo floats a circular image inside a block of text. Select different shape functions to see how the text reflow changes. Toggle the color scheme to verify the effect in both modes:

Shape Outside

Color scheme
Floated sample photo Typography and layout have always been intertwined. In print, designers routinely wrap body text around images, pull quotes, and decorative elements to create visual rhythm on the page. The web inherited rectangular boxes from its document roots, and for years that meant text could only wrap around sharp right-angled edges. Shape-outside changes that. It lets inline content follow curves, angles, and organic contours so your web layouts can achieve the same editorial feel that print designers have used for decades. The text you are reading right now is wrapping around the floated image to the left. Change the shape function above and watch how the flow adapts to each new geometry. Notice how circle and ellipse create smooth curves while polygon produces angular edges. Each shape tells the text to reflow differently, and the browser recalculates the wrap path in real time as the container resizes.
shape-outside: circle(50%);

Teaching Video Checklist

When you record your teaching video, make sure your teammates come away understanding these concepts:

  • Why float is still the right tool for text wrapping even though it is no longer used for page layout
  • At least three shape functions demonstrated live: circle(), polygon(), and one more of your choice
  • How shape-outside and clip-path work together (shape controls the flow, clip controls the visibility)
  • The shape-margin property and why text needs breathing room from the shape edge
  • The responsive reflow problem: what happens at narrow widths and how to disable the float at a breakpoint
  • A clear comparison of when to use shape-outside on a float versus when grid or flexbox is the better choice

Show a working editorial layout with text flowing around at least one shaped element. Resize the browser during the demo so your teammates can see how the reflow behaves at different widths and where it breaks down.

Resources