Summary
The shape-outside
CSS property uses shape values to define the float area for a float and will cause inline content to wrap around the shape instead of the float's bounding box.
Initial value | none |
---|---|
Applies to | floats |
Inherited | no |
Media | visual |
Computed value | as defined for <basic-shape> (with <shape-box> following, if supplied), the <image> with its URI made absolute, otherwise as specified. |
Animatable | yes, as basic-shape |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
/* Keyword values */ shape-outside: none; shape-outside: margin-box; shape-outside: content-box; shape-outside: border-box; shape-outside: padding-box; /* Function values */ shape-outside: circle(); shape-outside: ellipse(); shape-outside: inset(10px 10px 10px 10px); shape-outside: polygon(10px 10px, 20px 20px, 30px 30px); /* <url> value */ shape-outside: url(image.png); /* Global values */ shape-outside: initial; shape-outside: inherit; shape-outside: unset;
Values
none
- The float area is unaffected
<shape-box>
- If one of these is specified by itself the shape is computed based on one of '
margin-box
', 'border-box
', 'padding-box
' or 'content-box
' which us their respective boxes including curvature fromborder-radius
, similar to 'background-clip
'. - <basic-shape>
- The shape is computed based on the values of one of '
inset()
', 'circle()
', 'ellipse()
' or 'polygon()
'. If a<shape-box>
is also supplied, this defines the reference box for the<basic-shape>
function. If<shape-box>
is not supplied, then the reference box defaults to 'margin-box
'. - <image>
- The shape is extracted and computed based on the alpha channel of the specified
<image>
as defined by 'shape-image-threshold
'. - User agents must use the potentially CORS-enabled fetch method defined by the HTML5 specification for all URLs in a '
shape-outside
' value. When fetching, user agents must use "Anonymous" mode, set the referrer source to the stylesheet's URL and set the origin to the URL of the containing document. If this results in network errors such that there is no valid fallback image, the effect is as if the value 'none
' had been specified.
Interpolation
For interpolating between one basic shape and a second, the rules below are applied. The values in the shape functions interpolate as a simple list. The list values interpolate as length, percentage, or calc where possible. If list values are not one of those types but are identical (such as finding nonzero
in the same list position in both lists) those values do interpolate.
- Both shapes must use the same reference box.
- If both shapes are the same type, that type is
ellipse()
orcircle()
, and none of the radii use theclosest-side
or farthest-side keywords, interpolate between each value in the shape functions. - If both shapes are of type
inset()
, interpolate between each value in the shape functions. - If both shapes are of type
polygon()
, both polygons have the same number of vertices, and use the same<fill-rule>
, interpolate between each value in the shape functions. - In all other cases no interpolation is specified.
Formal syntax
none | <shape-box> || <basic-shape> | <image>where
<shape-box> = <box> | margin-box
<basic-shape> = <inset()> | <circle()> | <ellipse()> | <polygon()>where
<box> = border-box | padding-box | content-box
<inset()> = inset( <shape-arg>{1,4} [round <border-radius>]? )
<circle()> = circle( [<shape-radius>]? [at <position>]? )
<ellipse()> = ellipse( [<shape-radius>{2}]? [at <position>]? )
<polygon()> = polygon( [<fill-rule>,]? [<shape-arg> <shape-arg>]# )where
<shape-arg> = <length> | <percentage>
<shape-radius> = <length> | <percentage> | closest-side | farthest-side
<fill-rule> = nonzero | evenodd
Example
HTML Content
<div class="main"> <div class="left"></div> <div class="right"></div> <p> Sometimes a web page's text content appears to be funneling your attention towards a spot on the page to drive you to follow a particular link. Sometimes you don't notice. </p> </div>
CSS Content
.main { width: 500px; height: 200px; } .left { -webkit-shape-outside: polygon(0 0, 100% 100%, 0 100%); float: left; width: 40%; height: 12ex; background-color: lightgray; -webkit-clip-path: polygon(0 0, 100% 100%, 0 100%); } .right { -webkit-shape-outside: polygon(100% 0, 100% 100%, 0 100%); float: right; width: 40%; height: 12ex; background-color: lightgray; -webkit-clip-path: polygon(100% 0, 100% 100%, 0 100%); } p { text-align: center; }
Specifications
Specification | Status | Comment |
---|---|---|
CSS Shapes Module Level 1 The definition of 'shape-outside' in that specification. |
Candidate Recommendation | Initial definition |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 37 | No support | No support | 24 | 8.0 -webkit |
Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | No support | No support | No support | No support | 8.0 -webkit |