paint-order CSS property

Baseline 2024
Newly available

Since March 2024, this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.

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

css
/* 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 */

/* Global values */
paint-order: inherit;
paint-order: initial;
paint-order: revert;
paint-order: revert-layer;
paint-order: unset;

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 valuenormal
Applies totext elements
Inheritedyes
Computed valueas specified
Animation typediscrete

Formal syntax

paint-order = 
normal |
[ fill || stroke || markers ]

Examples

Reversing the paint order of stroke and fill

SVG

html
<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

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

Reversing the paint order of stroke and fill using HTML

To control the fill and stroke order in HTML, you can use the -webkit-text-stroke-color and -webkit-text-stroke-width CSS properties.

HTML

html
<div>stroke in front</div>
<div class="stroke-behind">stroke behind</div>

CSS

css
div {
  font-family: sans-serif;
  font-size: 50px;
  font-weight: bold;
  fill: black;
  padding-top: 10px;
  padding-bottom: 10px;
  -webkit-text-stroke-color: red;
  -webkit-text-stroke-width: 4px;
}

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

Result

Specifications

Specification
Scalable Vector Graphics (SVG) 2
# PaintOrderProperty

Browser compatibility

desktop mobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
paint-order
Chrome – Partial support
Chrome 35 – 122 (Release date: 2014-05-20)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Chrome – Full support
Chrome 123 (Release date: 2024-03-19)
footnote Full support
Edge – Partial support
Edge 79 – 122 (Release date: 2020-01-15)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Edge – Full support
Edge 123 (Release date: 2024-03-22)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – Partial support
Opera 22 – 108 (Release date: 2014-06-03)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Opera – Full support
Opera 109 (Release date: 2024-03-27)
footnote Full support
Safari – Partial support
Safari 8 – 10.1 (Release date: 2014-10-16)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 168601
Safari – Full support
Safari 11 (Release date: 2017-09-19)
footnote Full support
Chrome Android – Partial support
Chrome Android 35 – 122 (Release date: 2014-05-20)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Chrome Android – Full support
Chrome Android 123 (Release date: 2024-03-19)
footnote Full support
Firefox for Android – Full support
Firefox for Android 60 (Release date: 2018-05-09)
footnote Full support
Opera Android – Partial support
Opera Android 22 – 81 (Release date: 2014-06-17)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Opera Android – Full support
Opera Android 82 (Release date: 2024-05-02)
footnote Full support
Safari on iOS – Partial support
Safari on iOS 8 – 10.3 (Release date: 2014-09-17)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 168601
Safari on iOS – Full support
Safari on iOS 11 (Release date: 2017-09-19)
footnote Full support
Samsung Internet – Partial support
Samsung Internet 3 – 26 (Release date: 2015-04-10)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
Samsung Internet – Full support
Samsung Internet 27 (Release date: 2024-11-06)
footnote Full support
WebView Android – Partial support
WebView Android 37 – 122 (Release date: 2014-09-03)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 41372165
WebView Android – Full support
WebView Android 123 (Release date: 2024-03-19)
footnote Full support
WebView on iOS – Partial support
WebView on iOS 8 – 10.3 (Release date: 2014-09-17)
footnote Partial support
footnote Does not affect stroked HTML text, see bug 168601
WebView on iOS – Full support
WebView on iOS 11 (Release date: 2017-09-19)
footnote Full support
fill
Chrome – Full support
Chrome 35 (Release date: 2014-05-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – Full support
Opera 22 (Release date: 2014-06-03)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Full support
Chrome Android 35 (Release date: 2014-05-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 60 (Release date: 2018-05-09)
footnote Full support
Opera Android – Full support
Opera Android 22 (Release date: 2014-06-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 37 (Release date: 2014-09-03)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
markers
Chrome – Full support
Chrome 35 (Release date: 2014-05-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – Full support
Opera 22 (Release date: 2014-06-03)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Full support
Chrome Android 35 (Release date: 2014-05-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 60 (Release date: 2018-05-09)
footnote Full support
Opera Android – Full support
Opera Android 22 (Release date: 2014-06-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 37 (Release date: 2014-09-03)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
normal
Chrome – Full support
Chrome 35 (Release date: 2014-05-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – Full support
Opera 22 (Release date: 2014-06-03)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Full support
Chrome Android 35 (Release date: 2014-05-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 60 (Release date: 2018-05-09)
footnote Full support
Opera Android – Full support
Opera Android 22 (Release date: 2014-06-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 37 (Release date: 2014-09-03)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support
stroke
Chrome – Full support
Chrome 35 (Release date: 2014-05-20)
footnote Full support
Edge – Full support
Edge 79 (Release date: 2020-01-15)
footnote Full support
Firefox – Full support
Firefox 60 (Release date: 2018-05-09)
footnote Full support
Opera – Full support
Opera 22 (Release date: 2014-06-03)
footnote Full support
Safari – Full support
Safari 8 (Release date: 2014-10-16)
footnote Full support
Chrome Android – Full support
Chrome Android 35 (Release date: 2014-05-20)
footnote Full support
Firefox for Android – Full support
Firefox for Android 60 (Release date: 2018-05-09)
footnote Full support
Opera Android – Full support
Opera Android 22 (Release date: 2014-06-17)
footnote Full support
Safari on iOS – Full support
Safari on iOS 8 (Release date: 2014-09-17)
footnote Full support
Samsung Internet – Full support
Samsung Internet 3 (Release date: 2015-04-10)
footnote Full support
WebView Android – Full support
WebView Android 37 (Release date: 2014-09-03)
footnote Full support
WebView on iOS – Full support
WebView on iOS 8 (Release date: 2014-09-17)
footnote Full support

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
Partial support
Partial support
Has more compatibility info.

See also