Web/CSS/paint-order

From Get docs


The paint-order CSS property lets you control the order in which the fill and stroke (and painting markers) of text content and shapes are drawn.

Syntax

/* Normal */
paint-order: normal;

/* Single values */
paint-order: stroke; /* draw the stroke first, then fill and markers */
paint-order: markers; /* draw the markers first, then fill and stroke */

/* Multiple values */
paint-order: stroke fill; /* draw the stroke first, then the fill, then the markers */
paint-order: markers stroke fill; /* draw markers, then stroke, then fill */

If no value is specified, the default paint order is fill, stroke, markers.

When one value is specified, that one is painted first, followed by the other two in their default order relative to one another. When two values are specified, they will be painted in the order they are specified in, followed by the unspecified one.

Note: In the case of this property, markers are only appropriate when drawing SVG shapes involving the use of the marker-* properties (e.g. marker-start) and <marker> element. They do not apply to HTML text, so in that case, you can only determine the order of stroke and fill.


Values

normal
Paint the different items in normal paint order.
stroke, fill, markers
Specify some or all of these values in the order you want them to be painted in.

Formal definition

Initial value normal
Applies to text elements
Inherited yes
Computed value as specified
Animation type discrete

Formal syntax

normal | [ fill || stroke || markers ]

Examples

Reversing the paint order of stroke and fill

SVG

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
  <text x="10" y="75">stroke in front</text>
  <text x="10" y="150" class="stroke-behind">stroke behind</text>
</svg>

CSS

text {
  font-family: sans-serif;
  font-size: 50px;
  font-weight: bold;
  fill: black;
  stroke: red;
  stroke-width: 4px;
}

.stroke-behind {
  paint-order: stroke fill;
}

Result

Specifications

Specification Status Comment
Scalable Vector Graphics (SVG) 2The definition of 'paint-order' in that specification. Candidate Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
paint-order Chrome

Full support 35

Edge

Full support 17

Firefox

Full support 60

IE

No support No

Opera

Full support 22

Safari

Full support 8

WebView Android

Full support 37

Chrome Android

Full support 35

Firefox Android

Full support 60

Opera Android

Full support 22

Safari iOS

Full support 8

Samsung Internet Android

Full support 3.0

Legend

Full support  
Full support
No support  
No support