CSS paint-order Property

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 4 Examples
SVG Graphics

What You’ll Learn

The paint-order property controls the order in which fill, stroke, and markers are painted on SVG graphics. It is especially useful when thick strokes and fills overlap.

01

Fill & Stroke

Layer SVG paints.

02

Syntax

Reorder keywords.

03

normal

Default order.

04

stroke fill

Common pattern.

05

Markers

Arrowheads & dots.

06

SVG Text

Outlined lettering.

Introduction

The paint-order property in CSS is used to control the order in which the fill, stroke, and markers of SVG graphics are painted.

This property is particularly useful when you want to ensure that certain parts of your SVG are rendered in a specific sequence, which can affect the visual appearance and layering of the graphic.

Definition and Usage

By default, browsers paint the fill first, then the stroke, then markers such as arrowheads on lines. With paint-order, you can change that sequence — for example, painting the stroke before the fill so the fill sits on top.

This is most common on inline or embedded SVG shapes and SVG text that use both fill and stroke properties.

💡
Beginner Tip

If a thick stroke looks like it is eating into your fill, try paint-order: stroke fill. That paints the stroke first and the fill second, so the fill stays visually on top.

📝 Syntax

The syntax for the paint-order property allows you to specify the order of painting for the fill, stroke, and markers.

syntax.css
element {
  paint-order: fill stroke markers;
}

Each of the values (fill, stroke, markers) can be used in any order and can be omitted if not needed.

Basic Example

paint-order.css
svg rect {
  paint-order: stroke fill;
  stroke: blue;
  fill: lightblue;
  stroke-width: 5;
}

Syntax Rules

  • Use normal for the default order: fill, stroke, markers.
  • List one or more of fill, stroke, and markers in the order you want them painted.
  • Omitted values keep their default relative order after the values you listed.
  • The property applies to SVG shapes and SVG text with fill and/or stroke.
  • Combine with stroke, fill, and stroke-width to see the visual effect clearly.
  • Test in the browser — small order changes can look very different with thick strokes.

🎯 Default Value

The default value of the paint-order property is normal. This paints the fill first, then the stroke, and finally the markers.

⚡ Quick Reference

QuestionAnswer
Initial valuenormal
Applies toSVG shapes and text
InheritedYes
AnimatableNo
Common useControl fill/stroke layering in SVG

💎 Property Values

The paint-order property accepts keyword values that control the painting sequence of SVG presentation.

ValueExampleDescription
fillpaint-order: fill;Paints the fill of the SVG shape first.
strokepaint-order: stroke;Paints the stroke of the SVG shape.
markerspaint-order: markers;Paints markers such as arrowheads on lines.
normalpaint-order: normal;Default painting order of fill, stroke, and markers.
initialpaint-order: initial;Sets the property to its default value (normal).
inheritpaint-order: inherit;Inherits the value from the parent element.
normal stroke fill fill stroke markers

When Does paint-order Matter?

paint-order becomes important whenever fill and stroke overlap on SVG content:

  • Outlined SVG text — Use stroke fill so readable fill sits above a decorative stroke.
  • Icons and badges — Control whether a bold border appears on top of or behind the fill.
  • Charts and diagrams — Keep line markers visible relative to strokes and fills.
  • Thick strokes — Change overlap when stroke-width is large enough to cover the fill center.

On shapes with only fill or only stroke, changing paint order may show little or no visible difference.

👀 Live Preview

Compare default normal order with stroke fill on rectangles that share the same colors and stroke width.

normal

stroke fill

Examples Gallery

Start with the reference rectangle example, compare default and custom orders, style outlined text, and control marker layering.

▦ SVG Shapes

Use paint-order on SVG rectangles and other shapes — matching the reference example.

Example 1 — SVG Rectangle with Custom Paint Order

In this example, we’ll change the paint order of an SVG rectangle so that the stroke is painted before the fill.

paint-order-example.html
<style>
  svg rect {
    paint-order: stroke fill;
    stroke: blue;
    fill: lightblue;
    stroke-width: 5;
  }
</style>

<h1>SVG Rectangle with Custom Paint Order</h1>
<svg width="200" height="200">
  <rect x="50" y="50" width="100" height="100"></rect>
</svg>
Try It Yourself

How It Works

With paint-order: stroke fill, the browser paints the blue stroke first and the light blue fill second, so the fill appears on top inside the shape.

Example 2 — Compare Default and Custom Order

Place two rectangles side by side to see how normal and stroke fill differ with a thick stroke.

paint-order-compare.html
<style>
  .default rect { paint-order: normal; }
  .custom rect { paint-order: stroke fill; }
  rect {
    stroke: #1d4ed8;
    fill: #bfdbfe;
    stroke-width: 10;
  }
</style>
Try It Yourself

How It Works

Both rectangles use the same colors and stroke width. Only the paint order changes, which alters how much of the stroke remains visible around the fill.

📝 SVG Text & Markers

Apply paint order to outlined text and lines with arrow markers.

Example 3 — Outlined SVG Text

Use paint-order: stroke fill on SVG text so a thick stroke sits behind crisp fill lettering.

paint-order-text.html
<style>
  svg text {
    paint-order: stroke fill;
    stroke: #fbbf24;
    stroke-width: 6;
    fill: #ffffff;
    font-size: 48px;
  }
</style>

<svg width="320" height="90">
  <text x="10" y="60">Hello SVG</text>
</svg>
Try It Yourself

How It Works

Outlined text is easier to read when the fill is painted after the stroke. Without stroke fill, a thick stroke can dominate the letter shapes.

Example 4 — Line with Markers

Reorder markers relative to stroke on a line that uses an SVG arrow marker.

paint-order-markers.html
<style>
  .arrow-line {
    paint-order: stroke markers fill;
    stroke: #0f766e;
    stroke-width: 6;
    marker-end: url(#arrowhead);
  }
</style>
Try It Yourself

How It Works

Markers are a third paint layer on lines and paths. Custom order helps when arrowheads should appear above or below the stroke in complex diagrams.

Understanding fill, stroke, and markers

Think of an SVG shape as three paint layers. fill colors the inside, stroke outlines the edge, and markers add decorations such as arrowheads on lines.

The default normal order is fill → stroke → markers. Use paint-order when you need a different stacking result without changing your colors or geometry.

paint-layers.css
/* Default */
svg path {
  paint-order: normal; /* fill, stroke, markers */
}

/* Common custom order */
svg text {
  paint-order: stroke fill;
}

🧠 How paint-order Works

1

SVG defines shape geometry

A rectangle, path, line, or text element defines what will be drawn.

SVG markup
2

You set fill, stroke, and paint-order

CSS chooses colors, stroke width, and the order those paints are applied.

CSS rule
3

The browser paints each layer

Layers are drawn in your chosen sequence. Later layers appear on top of earlier ones.

Rendering
=

Precise visual layering

Stroke, fill, and markers overlap exactly the way your design needs.

Browser Compatibility

The paint-order property is supported in most modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. However, it is always a good practice to test your website across different browsers to ensure compatibility.

SVG · Widely supported

Reliable SVG paint-order control

Chrome, Firefox, Safari, Edge, and Opera support paint-order on SVG content.

94% Modern browser support
Google Chrome 35+ · Desktop & Mobile
Full support
Mozilla Firefox 60+ · Desktop & Mobile
Full support
Apple Safari 8+ · macOS & iOS
Full support
Microsoft Edge 79+ · Chromium
Full support
Opera 22+ · Modern versions
Full support

Testing tip

Compare normal and stroke fill side by side in your target browsers, especially when using thick strokes or SVG text outlines.

paint-order property 94% supported

Bottom line: paint-order is well supported for SVG in modern browsers. Always verify the visual result when stroke widths are large.

Conclusion

The paint-order property is a valuable tool for web developers working with SVG graphics.

By controlling the painting order of fill, stroke, and markers, you can achieve precise visual effects and ensure that your graphics are rendered exactly as intended. Experiment with different painting orders to see how this property can enhance the appearance of your SVG elements.

💡 Best Practices

✅ Do

  • Use paint-order: stroke fill for outlined SVG text and icons
  • Compare normal and custom order when using thick stroke-width
  • Keep stroke and fill colors defined in CSS for easy tuning
  • Test SVG graphics in every target browser
  • Document non-default paint order when it is required for the design

❌ Don’t

  • Expect paint-order to affect plain HTML boxes without SVG presentation
  • Assume a custom order fixes layout problems — geometry still matters
  • Use extreme stroke widths without checking readability
  • Forget that omitted values still follow the default relative order
  • Skip visual testing on mobile browsers for icon sets

Key Takeaways

Knowledge Unlocked

Five things to remember about paint-order

Use these points when layering fill, stroke, and markers in SVG.

5
Core concepts
02

normal Default

fill → stroke → markers.

Default
03

stroke fill

Fill on top.

Pattern
📝 04

SVG Text

Outlined lettering.

Use case
05

markers

Arrowheads on lines.

Keyword

❓ Frequently Asked Questions

The paint-order property controls the order in which fill, stroke, and markers are painted on SVG shapes and text. Changing the order can change how thick strokes and fills overlap.
The default value is normal, which paints fill first, then stroke, then markers.
Use stroke fill when you want the fill painted on top of the stroke. This is common for outlined SVG text and shapes where a thick stroke should sit behind the fill.
paint-order is mainly useful for SVG graphics and text that have fill and stroke. It does not affect typical block-level HTML elements without SVG presentation.
Yes. You can list fill, stroke, and markers in any order and omit values you do not need. Omitted parts keep their default relative order after the listed values.

Practice in the Live Editor

Open the HTML editor, add inline SVG, and experiment with paint-order on shapes and text.

HTML Editor →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful