Shapes and paint implications
Definition and purpose
shape-outside changes the exclusion area around a float so inline text can follow a nonrectangular boundary. It does not paint that shape. A clip-path can independently make the float look like the exclusion geometry.
Circular exclusion
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #b { width: 300px; display: flow-root; line-height: 20px; } #a { float: left; width: 100px; height: 100px; background: blue; } #a { shape-outside: circle(50%); clip-path: circle(50%); } </style> </head> <body> <article id="b"> <div id="a" aria-hidden="true"></div> <span id="t">Words wrap around the floated shape. Words wrap around the floated shape. Words wrap around the floated shape. Words wrap around the floated shape.</span> </article> </body></html>The float is still a square box but the text follows its circular exclusion.
Syntax and mental model
Apply float first. circle(50%) uses the reference box to determine a radius; polygon() permits a sloped boundary. shape-margin increases the exclusion area within the applicable float constraints. For image-defined shapes, shape-image-threshold selects alpha coverage, subject to image access restrictions. Text lines interact with the shape, but the floated element’s rectangular layout bounds are still measurable. Compare the first text line before and after removing shape-outside.
Add breathing room
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>CSS practice</title> <style> body { margin: 0; font: 16px sans-serif; color: #172033; background: white; } #b { width: 300px; display: flow-root; line-height: 20px; } #a { float: left; width: 100px; height: 100px; background: blue; } #a { shape-outside: circle(35%); clip-path: circle(35%); shape-margin: 8px; } </style> </head> <body> <article id="b"> <div id="a" aria-hidden="true"></div> <span id="t">Words wrap around the floated shape. Words wrap around the floated shape. Words wrap around the floated shape. Words wrap around the floated shape.</span> </article> </body></html>The wrapping boundary includes additional spacing around the circle.
Common mistakes
Do not expect clip-path alone to change text wrapping. A non-floated box does not acquire a float exclusion area just by setting shape-outside.
Practice and next steps
After trying the examples, complete the linked coding exercise and review questions. Predict the result before running your code. Prerequisite: Masking and clipping. Next lesson: Scroll snap and scroll padding.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Shapes and paint implications — knowledge check
Five questions on shapes and paint implications.
Which property changes text wrapping around a float?
Which declaration shapes the painted region?
What does shape-margin add?
What must be true for shape-outside to affect wrapping?
Does the float’s rectangular bounding box disappear?