CKTIS / CSS
CSS property `paint-order`
`paint-order` changes the painting sequence of `fill`, `stroke`, and `markers` for SVG shapes and text; `normal` uses that default sequence.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
normal | [ fill || stroke || markers ]paint-order changes the painting sequence of fill, stroke, and markers for SVG shapes and text; normal uses that default sequence.
The example rasterizes two SVG rectangles and proves at pixel level that specifying only stroke paints the stroke before the fill: the inner half of a thick stroke is covered by red fill while its outer half remains blue.
Grammar: normal | [ fill || stroke || markers ].
Listed operations run from left to right, and omitted operations are appended in their normal relative order. The property is inherited, applies to SVG graphics, and does not change stroke geometry.
Examples
<!doctype html><meta charset="utf-8"><svg id="stage" xmlns="http://www.w3.org/2000/svg" width="140" height="80"><rect id="normal" x="20" y="20" width="40" height="40" fill="red" stroke="blue" stroke-width="20"/><rect id="ordered" x="90" y="20" width="40" height="40" fill="red" stroke="blue" stroke-width="20" style="paint-order:stroke"/></svg><pre id="result"></pre><script>const rasterize=svg=>new Promise((resolve,reject)=>{const image=new Image();image.onload=()=>{const canvas=document.createElement('canvas');canvas.width=Number(svg.getAttribute('width'));canvas.height=Number(svg.getAttribute('height'));const context=canvas.getContext('2d');context.drawImage(image,0,0);resolve(context)};image.onerror=()=>reject(new Error('SVG rasterization failed'));image.src='data:image/svg+xml;charset=utf-8,'+encodeURIComponent(new XMLSerializer().serializeToString(svg))});const rgb=(context,x,y)=>[...context.getImageData(x,y,1,1).data].slice(0,3).join(',');(async()=>{const context=await rasterize(stage),normalInner=rgb(context,25,40),orderedInner=rgb(context,95,40),normalOuter=rgb(context,15,40),orderedOuter=rgb(context,85,40),computed=getComputedStyle(ordered).paintOrder;if(normalInner!=='0,0,255'||orderedInner!=='255,0,0'||normalOuter!=='0,0,255'||orderedOuter!=='0,0,255'||computed!=='stroke')throw new Error('paint-order pixel mismatch '+[normalInner,orderedInner,normalOuter,orderedOuter,computed]);result.textContent='inner='+normalInner+'/'+orderedInner+'; outer='+normalOuter+'/'+orderedOuter+'; computed='+computed})().catch(error=>result.textContent='ERROR:'+error.message);</script>Result
inner=0,0,255/255,0,0; outer=0,0,255/0,0,255; computed=stroke
The example rasterizes two SVG rectangles and proves at pixel level that specifying only `stroke` paints the stroke before the fill: the inner half of a thick stroke is covered by red fill while its outer half remains blue.