This draft contains the features of CSS relating to wrapping content around and inside shapes. It (implicitly for now) includes and extends the functionality of CSS Shapes Level 1 [CSS-SHAPES]. The main points of extension compared to level 1 include additional ways of defining shapes, defining an exclusion area using a shape, and restricting an element’s content area using a shape.
CSS is a language for describing the rendering of structured documents
(such as HTML and XML)
on screen, on paper, etc.
Status of this document
This is a public copy of the editors’ draft.
It is provided for discussion only and may change at any moment.
Its publication here does not imply endorsement of its contents by W3C.
Don’t cite this document other than as work in progress.
Please send feedback
by filing issues in GitHub (preferred),
including the spec code “css-shapes” in the title, like this:
“[css-shapes] …summary of comment…”.
All issues and comments are archived.
Alternately, feedback can be sent to the (archived) public mailing list [email protected].
Level 1 of this specification defined properties
to control the geometry of an element’s float area.
This level defines how shapes apply to exclusions.
It also includes a shape-inside property
for applying a shape to an element’s content area.
Finally, it defines new ways of specifying shapes for all of these applications.
1.1. Value Definitions
This specification follows the CSS property definition conventions from [CSS2] using the value definition syntax from [CSS-VALUES-3].
Value types not defined in this specification are defined in CSS Values & Units [CSS-VALUES-3].
Combination with other CSS modules may expand the definitions of these value types.
In addition to the property-specific values listed in their definitions,
all properties defined in this specification
also accept the CSS-wide keywords as their property value.
For readability they have not been repeated explicitly.
2. Terminology
exclusion area
The area used for excluding inline flow content around an exclusion box.
The exclusion area is equivalent to the border box for an exclusion box.
This specification’s shape-outside property
can be used to define arbitrary, non-rectangular exclusion areas.
The shape-inside property also defines an exclusion area,
but in this case it is the area outside the shape that inline content avoids.
float area
The area used for wrapping content around a float element.
By default, the float area is the float element’s margin box.
This specification’s shape-outside property can be used
to define arbitrary, non-rectangular float areas.
content area
The content area is normally used for layout of the inline flow content of a box.
3. Shapes
Shapes define arbitrary geometric contours
around which inline content flows.
The shape-outside property defines the float area for a float,
and the exclusion area for an exclusion.
One suggestion is to define a shape based on an element’s rendered content.
This could have security implications.
Another suggestion is to add something to an image() function
that determines the relevant pixels to use
(both for defining a shape and for display).
7. Fetching external shapes
To fetch an external resource for a shape, either an SVG or an image, given a CSS style declarationdeclaration, fetch a style resource given a value,
with ruleOrDeclaration being declaration,
destination "image",
CORS mode "cors",
and processResponse being the following steps given responseres and null, failure or
a byte stream byteStream:
If byteStream is a byte stream,
apply the image or SVG to the appropriate shape-accepting property.
Note: shapes require CORS mode as their effect is detected by the document.
A shape can be declared with the shape-outside property,
with possible modifications from the shape-margin property.
The shape defined by the shape-outside and shape-margin properties
changes the geometry of a float element’s float area and an exclusion element’s exclusion area.
A shape can be declared with the shape-inside property,
with possible modifications from the shape-padding property.
The shape defined by the shape-inside and shape-padding properties
defines an exclusion area that contributes to the element’s wrapping context.
The shape-inside property applies to all block-level elements.
The red box illustrates an exclusion element’s content box,
which is unmodified and subject to normal CSS positioning
(here absolute positioning).
<styletype="text/css">.exclusion{wrap-flow:both;position:absolute;top:25%;left:25%;width:50%;height:50%;shape-outside: circle(50%at50%50%);border:1pxsolidred;}style><divstyle=”position:relative;”><divclass=”exclusion”>div>
Lorem ipsum dolor sit amet...
div>
The shape-inside property adds one or more exclusion areas
to the element’s wrapping context.
This modifies the normal rectangular shape of the content area
to a possibly non-rectangular wrapping area.
The exclusion areas are defined by subtracting the shape from the element’s content area.
Any part of the shape outside the element’s content area has no effect.
The values of this property have the following meanings:
auto
The shape is computed based on the content box of the element.
outside-shape
The shape is computed based on
the shape defined by the shape-outside
and shape-margin properties.
The shape is computed based
on the values of one of
the functions.
If the references an SVG shape element,
that element defines the shape.
Otherwise, if the references an image,
the shape is extracted and computed
based on the alpha channel
of the specified image.
If the does not reference
an SVG shape element or an image,
the effect is as if the value auto had been specified.
display
The shape is computed based on the shape of the display
as described in css-round-display.
The shape-inside property may not apply on some elements
such as elements with a computed display value of table.
Effect of shape-inside on inline content.
Overflow content avoids
the exclusion area(s) added
by shape-inside and shape-padding (as well as any other exclusion areas
in the element’s wrapping context).
In other words,
overflow continues outside
the rectangular bounds of the element.
improve the illustration above,
using text to show overflow instead of grey boxes.
When a shape-inside has a definite size
(no percentages used in the shape’s definition)
an auto-sized element should use the shape
as a constraint in determining its maximum size.
Should we add an alpha/luminance switch
to determine which values we use
from the shape-image source?
This could just be a keyword
on the shape-image-threshold property.
Whatever we go with should be compatible
with the alpha/luminance switch from mask sources.
The shape-padding property adds padding to a shape-inside.
This defines a new shape where every point
is the specified distance from the shape-inside.
This property takes on positive values only.
Sets the padding of the shape to the specified value.
A shape-padding creating an offset from a circular shape-inside.
The light blue rectangles represent inline content
affected by the shape created by the padding.
Note: The shape-padding property only affects layout of content
inside the element it applies to
while the shape-margin property only affects layout of content
outside the element.
Privacy Considerations
No new privacy considerations have been reported on this specification.
Security Considerations
No new security considerations have been reported on this specification.
Conformance
Document conventions
Conformance requirements are expressed with a combination of
descriptive assertions and RFC 2119 terminology. The key words “MUST”,
“MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”,
“RECOMMENDED”, “MAY”, and “OPTIONAL” in the normative parts of this
document are to be interpreted as described in RFC 2119.
However, for readability, these words do not appear in all uppercase
letters in this specification.
All of the text of this specification is normative except sections
explicitly marked as non-normative, examples, and notes. [RFC2119]
Examples in this specification are introduced with the words “for example”
or are set apart from the normative text with class="example",
like this:
This is an example of an informative example.
Informative notes begin with the word “Note” and are set apart from the
normative text with class="note", like this:
Note, this is an informative note.
Advisements are normative sections styled to evoke special attention and are
set apart from other normative text with , like
this: UAs MUST provide an accessible alternative.
Tests
Tests relating to the content of this specification
may be documented in “Tests” blocks like this one.
Any such block is non-normative.
Conformance classes
Conformance to this specification
is defined for three conformance classes:
A style sheet is conformant to this specification
if all of its statements that use syntax defined in this module are valid
according to the generic CSS grammar and the individual grammars of each
feature defined in this module.
A renderer is conformant to this specification
if, in addition to interpreting the style sheet as defined by the
appropriate specifications, it supports all the features defined
by this specification by parsing them correctly
and rendering the document accordingly. However, the inability of a
UA to correctly render a document due to limitations of the device
does not make the UA non-conformant. (For example, a UA is not
required to render color on a monochrome monitor.)
An authoring tool is conformant to this specification
if it writes style sheets that are syntactically correct according to the
generic CSS grammar and the individual grammars of each feature in
this module, and meet all other conformance requirements of style sheets
as described in this module.
Partial implementations
So that authors can exploit the forward-compatible parsing rules to
assign fallback values, CSS renderers must treat as invalid (and ignore
as appropriate) any at-rules, properties, property values, keywords,
and other syntactic constructs for which they have no usable level of
support. In particular, user agents must not selectively
ignore unsupported component values and honor supported values in a single
multi-value property declaration: if any value is considered invalid
(as unsupported values must be), CSS requires that the entire declaration
be ignored.
Implementations of Unstable and Proprietary Features
Once a specification reaches the Candidate Recommendation stage,
non-experimental implementations are possible, and implementors should
release an unprefixed implementation of any CR-level feature they
can demonstrate to be correctly implemented according to spec.
To establish and maintain the interoperability of CSS across
implementations, the CSS Working Group requests that non-experimental
CSS renderers submit an implementation report (and, if necessary, the
testcases used for that implementation report) to the W3C before
releasing an unprefixed implementation of any CSS features. Testcases
submitted to W3C are subject to review and correction by the CSS
Working Group.
Further information on submitting testcases and implementation reports
can be found from on the CSS Working Group’s website at http://www.w3.org/Style/CSS/Test/.
Questions should be directed to the [email protected] mailing list.
One suggestion is to define a shape based on an element’s rendered content.
This could have security implications. ↵
Another suggestion is to add something to an image() function
that determines the relevant pixels to use
(both for defining a shape and for display). ↵
improve the illustration above,
using text to show overflow instead of grey boxes. ↵
Firefox3.5+Safari9.1+Chrome55+Opera?Edge79+Edge (Legacy)NoneIENoneFirefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
Firefox62+Safari10.1+Chrome37+Opera?Edge79+Edge (Legacy)?IENoneFirefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
Firefox62+Safari10.1+Chrome37+Opera?Edge79+Edge (Legacy)?IENoneFirefox for Android?iOS Safari10.3+Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
Firefox62+Safari10.1+Chrome37+Opera?Edge79+Edge (Legacy)?IENoneFirefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?
Firefox54+Safari10.1+Chrome37+Opera?Edge79+Edge (Legacy)?IENoneFirefox for Android?iOS Safari?Chrome for Android?Android WebView?Samsung Internet?Opera Mobile?