CSS Portal

CSS paint-order Property

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The paint-order property determines the order in which the visible parts of a vector shape are drawn — for example the fill, the stroke, and any markers — so it changes which parts cover others when those parts overlap. It is a visual layering control only: it does not alter the geometric path, bounding box, hit testing, event targets, or document order. Because it operates on the internal painting sequence of an element, you can get different visual results without changing markup or duplicating geometry.

One common practical use is to resolve unwanted overlap between a shape's outline and its interior artwork: by changing the internal painting sequence you can paint the stroke beneath the fill to produce an inset look, or paint the stroke last to create a crisp outline that sits above the fill. This can be useful for thick strokes, complex joins, or when fills include patterns or gradients that you don't want obscured by the stroke. The property is especially relevant when working with SVG shapes and path markers where the order of stroke, fill, and markers visibly matters; consider how it interacts with the individual presentation properties like fill and stroke when designing the final appearance.

Because paint-order only affects painting order, it interacts with blending and effects in ways that can be important for final rendering. If you use blending controls such as mix-blend-mode, or apply graphical effects via filter, the result can change substantially depending on which part of the element is painted first. Likewise, overall transparency is handled differently depending on painting order — see opacity for how translucency compositing works. Note that this is distinct from how elements are stacked relative to each other in the document: stacking/ordering between elements is controlled by mechanisms like z-index and can be affected by context-creating properties such as transform, whereas paint-order is local to the element’s own parts.

In practice, changing painting order is a lightweight and expressive tool for designers who need precise visual layering without adding extra DOM or duplicating shapes. However, because it affects how browsers composite an element’s content, care is warranted: complex combinations of painting-order changes with filters, blend modes, or frequent dynamic updates can increase the work the renderer must do and may have performance implications. When you need persistent, predictable layering for complex visuals, sometimes splitting artwork into separate elements (and controlling inter-element stacking) is a clearer alternative than relying solely on internal painting order.

Definition

Initial value
normal
Applies to
text elements
Inherited
yes
Computed value
as specified
Animatable
yes
JavaScript syntax
object.style.paintOrder

Syntax

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

Values

  • normalPaint the different items in normal paint order.
  • stroke, fill, markersSpecify some or all of these values in the order you want them to be painted in.

Example

<div class='example'>
<svg width='320' height='100' viewBox='0 0 320 100' xmlns='http://www.w3.org/2000/svg' class='sample'>
<text x='16' y='64' class='label default'>Paint order: default</text>
</svg>

<svg width='320' height='100' viewBox='0 0 320 100' xmlns='http://www.w3.org/2000/svg' class='sample'>
<text x='16' y='64' class='label reversed'>Paint order: stroke then fill</text>
</svg>
</div>
body {
  margin: 24px;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial;
  background: #f6f7fb;
}

.example {
  display: flex;
  gap: 18px;
  align-items: center;
}

.sample {
  background: #ffffff;
  border: 1px solid #e6e9ef;
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(16, 24, 40, 0.04);
}

.label {
  font-size: 36px;
  font-weight: 700;
  fill: #2563eb;          /* blue fill */
  stroke: #ef4444;        /* red stroke */
  stroke-width: 10px;
  vector-effect: non-scaling-stroke;
  paint-order: normal;    /* default: fill then stroke */
}

/* Change the paint order so the stroke is painted before the fill */
.reversed {
  paint-order: stroke fill;
}

/* target the second SVG's text to apply the alternate paint order */
.sample:nth-child(2) .label {
  paint-order: stroke fill;
}

Browser Support

The following information will show you the current browser support for the CSS paint-order property. Hover over a browser icon to see the version that first introduced support for this CSS property.

This property is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 1st January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!