Getting Creative With Shape Outside

Transform your layouts with CSS shapes that break free from rectangular boxes and create magazine-style text flows

What Is CSS Shape-Outside?

CSS shape-outside is one of those properties that can transform a visually flat design into something that feels intentional, artistic, and alive. While most images sit inside rectangular boxes with text flowing strictly above or below, shape-outside breaks free from these constraints by allowing inline content to wrap around non-rectangular shapes defined by images or CSS functions.

For shape-outside to work, the element must be floated and have a defined width. The property then uses either an image's alpha channel or CSS shape functions to define the actual wrapping area. This means the visual image and the text-wrapping shape can be controlled independently, giving designers unprecedented control over how content flows around visual elements.

As documented by MDN Web Docs, this CSS Shapes Module Level 1 property enables layouts that traditionally required complex workarounds or print-specific design approaches. Combined with modern techniques like CSS Grid, shape-outside opens up creative possibilities that bring print-inspired design to the web.

Browser Support Since 2020

4

Major Browsers Supported

100%

Percent Baseline Available

5+

Shape Functions

Browser Support and Baseline Status

Shape-outside is a Baseline Widely Available feature, meaning it has been supported across all major browsers since January 2020. Browser support includes Chrome, Edge, Firefox, and Safari, making it safe to use in production without significant fallback concerns. The feature is part of the CSS Shapes Module Level 1 specification and works consistently across implementations, so you can confidently use it in projects targeting modern browsers.

The Relationship Between shape-outside and float

Understanding float is essential because shape-outside only works with floated elements. When you float an image left or right, text naturally wraps around it, but only within the rectangular bounds of that element's box model. Shape-outside modifies this behavior by replacing the default rectangular float area with a custom shape, as explained in Google's web.dev guide on CSS shapes.

This fundamental relationship means that any float-based layout technique can be enhanced with shape-outside to create more dynamic and visually interesting designs that break free from the constraints of rectangular boxes. For advanced positioning scenarios, you may also want to explore sticky positioning techniques that complement float-based layouts.

Shape Types Available

CSS shape-outside supports multiple ways to define wrapping shapes

Image Alpha Channels

Extract shapes from PNG/WebP images using transparency to define text flow areas

Circle & Ellipse

Create rounded shapes with precise control over radius and position

Inset Rectangles

Define rectangular shapes with optional rounded corners

Polygon Shapes

Build complex custom shapes using multiple coordinate points

Shape Margin

Add spacing between the shape and wrapping text for readability

Image Threshold

Control which parts of an image's alpha channel define the shape

Image-Based Shapes

One of the most powerful features of shape-outside is its ability to extract a shape from an image's alpha channel. This means you can create a PNG or WebP image with a transparent background, and the shape-outside property will use the opaque parts of that image to define where text should flow, as demonstrated in CSS-Tricks' comprehensive guide.

Using Alpha Channels

The shape-image-threshold property controls which parts of the alpha channel are used, with values from 0 to 1 determining the opacity cutoff. Here's a basic example:

img {
 float: left;
 width: 300px;
 shape-outside: url('image-with-transparent-background.png');
 shape-image-threshold: 0.5;
 shape-margin: 1rem;
}

The shape-margin property adds spacing between the shape and the wrapping text, creating visual breathing room and improving readability, as documented on MDN Web Docs.

CSS Basic Shape Functions
1/* Circle shape */2.circle-element {3 float: left;4 shape-outside: circle(50% at center);5}6 7/* Ellipse shape */8.oval-element {9 float: right;10 shape-outside: ellipse(150px 100px at 20% 20%);11}12 13/* Inset with rounded corners */14.inset-shape {15 shape-outside: inset(10px 20px 30px 40px round 15px);16}17 18/* Custom polygon */19.custom-polygon {20 shape-outside: polygon(21 0% 0%,22 100% 0%,23 100% 75%,24 75% 75%,25 75% 100%,26 50% 75%,27 0% 75%28 );29}

Creative Layout Techniques

Multiple Image Shapes in a Single Layout

When adding images to long-form content, consider how they can help shape someone's experience. Flowing text around images can slow readers down, making their experience more immersive. Visually, it brings text and image into a closer relationship, making them feel part of a shared composition rather than isolated elements, as explored in CSS-Tricks' creative guide.

Creating Faux-Centered Images

One of the more advanced techniques involves creating the illusion of a centered image with text flowing around both sides. Since there's no center value for floats, this requires splitting an image into two halves--one floated left and one floated right--then applying shape-outside to each half so they appear to form a complete centered image.

Text Between Shapes

For maximum creative impact, you can flow text between multiple shapes positioned in opposition to each other. This technique works well for creating magazine-style layouts where text acts as a dynamic element, flowing between images or design elements rather than being confined to standard column layouts.

These advanced techniques demonstrate how shape-outside can transform modern CSS layouts from predictable grids into artistic compositions that engage users. When combined with line clamping techniques, you can create sophisticated content presentations that control both text flow and truncation.

Best Practices and Performance

Responsive Shape Handling

When implementing shape-outside, consider how shapes behave across different screen sizes. Percentage-based shapes scale with their container, while pixel-based shapes maintain fixed dimensions. For responsive designs, use CSS media queries to adjust shape definitions at different breakpoints, as recommended in Google's web.dev CSS guide.

Image-based shapes using URLs will scale with the element, which means the shape automatically adapts as the image resizes. This makes them inherently responsive, though you may want to adjust shape-margin values at different breakpoints to maintain appropriate spacing.

Accessibility Considerations

While shape-outside creates visually interesting layouts, ensure text remains readable and the content remains accessible to all users. Some assistive technologies may not convey shape-based text flows, so the content should make sense when rendered in a standard rectangular flow. Test your implementations with screen readers and ensure adequate contrast regardless of the wrapping effect.

Combining with clip-path

For complete visual control, combine shape-outside with clip-path to create elements that have both a visible shape and a matching text flow area:

.artistic-element {
 float: left;
 width: 300px;
 clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
 shape-outside: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

This approach ensures visual consistency between what's seen and how text flows, creating cohesive layouts that showcase attention to detail in every project.

Frequently Asked Questions

Ready to Transform Your Web Design?

Our expert developers use modern CSS techniques like shape-outside to create visually stunning, performant websites.

Sources

  1. CSS-Tricks: Getting Creative With shape-outside - Comprehensive guide covering creative applications with practical examples
  2. MDN Web Docs: shape-outside - Official Mozilla documentation with complete technical reference
  3. web.dev: Paths, Shapes, Clipping and Masking - Google's official CSS learning resource