paint-order

  • Revision slug: paint-order
  • Revision title: paint-order
  • Revision id: 346859
  • Created:
  • Creator: Heycam
  • Is current revision? No
  • Comment Moved page to SVG/Attribute/paint-order.

Revision Content

« SVG Attribute reference home

The paint-order attribute specifies the order that the fill, stroke and markers of a given shape or text element is painted. Its default value is normal, which indicates that the fill will be painted first, then the stroke, and finally the markers. To specify a different order, a white space separated list of keywords fill, stroke and markers can be used. If any of the three painting components is omitted, then they will be painted in their default order after the specified components. For example, using stroke is equivalent to stroke fill markers.

As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet.

Usage context

Categories Presentation attribute
Value normal | [ fill || stroke || markers ] | inherit
Animatable Yes
Normative document SVG 2

Example

<svg xmlns="http://www.w3.org/2000/svg" width="400" height="200">
  <linearGradient id="g" x1="0" y1="0" x2="0" y2="1">
    <stop stop-color="#888"/>
    <stop stop-color="#ccc" offset="1"/>
  </linearGradient>
  <rect width="400" height="200" fill="url(#g)"/>
  <g fill="crimson" stroke="white" stroke-width="6" stroke-linejoin="round"
     text-anchor="middle" font-family="sans-serif" font-size="50px" font-weight="bold">
    <text x="200" y="75">stroke over</text>
    <text x="200" y="150" paint-order="stroke">stroke under</text>
  </g>
</svg>

The example would be rendered as follows:

An image showing how the paint-order example looks in a UA that supports the paint-order property.

Elements

The following elements can use the paint-order attribute:

Revision Source

<p>« <a href="/en/SVG/Attribute" title="en/SVG/Attribute">SVG Attribute reference home</a></p>
<p>The <code>paint-order</code> attribute specifies the order that the fill, stroke and markers of a given shape or text element is painted. Its default value is <strong>normal</strong>, which indicates that the fill will be painted first, then the stroke, and finally the markers. To specify a different order, a white space separated list of&nbsp;keywords <strong>fill</strong>, <strong>stroke</strong> and <strong>markers</strong> can be used. If any of the three painting components is omitted, then they will be painted in their default order after the specified components. For example, using <strong>stroke</strong> is equivalent to <strong>stroke fill markers</strong>.</p>
<p>As a presentation attribute, it also can be used as a property directly inside a CSS stylesheet.</p>
<h2 id="Usage_context">Usage context</h2>
<table class="standard-table">
  <tbody>
    <tr>
      <th>Categories</th>
      <td>Presentation attribute</td>
    </tr>
    <tr>
      <th>Value</th>
      <td>normal | [ fill || stroke || markers ] | inherit</td>
    </tr>
    <tr>
      <th>Animatable</th>
      <td>Yes</td>
    </tr>
    <tr>
      <th>Normative document</th>
      <td><a class="external" href="http://www.w3.org/TR/SVG2/painting.html#PaintOrderProperty" title="http://www.w3.org/TR/SVG/painting.html#StrokeWidthProperty">SVG 2</a></td>
    </tr>
  </tbody>
</table>
<h2 id="Example">Example</h2>
<pre>
&lt;svg xmlns="http://www.w3.org/2000/svg" width="400" height="200"&gt;
&nbsp; &lt;linearGradient id="g" x1="0" y1="0" x2="0" y2="1"&gt;
&nbsp;&nbsp;&nbsp; &lt;stop stop-color="#888"/&gt;
&nbsp;&nbsp;&nbsp; &lt;stop stop-color="#ccc" offset="1"/&gt;
&nbsp; &lt;/linearGradient&gt;
&nbsp; &lt;rect width="400" height="200" fill="url(#g)"/&gt;
&nbsp; &lt;g fill="crimson" stroke="white" stroke-width="6" stroke-linejoin="round"
&nbsp;&nbsp;&nbsp;&nbsp; text-anchor="middle" font-family="sans-serif" font-size="50px" font-weight="bold"&gt;
&nbsp;&nbsp;&nbsp; &lt;text x="200" y="75"&gt;stroke over&lt;/text&gt;
&nbsp;&nbsp;&nbsp; &lt;text x="200" y="150" paint-order="stroke"&gt;stroke under&lt;/text&gt;
&nbsp; &lt;/g&gt;
&lt;/svg&gt;</pre>
<p>The example would be rendered as follows:</p>
<p><img alt="An image showing how the paint-order example looks in a UA that supports the paint-order property." src="/files/4567/paint-order-2.png" style="width: 400px; height: 200px;" /></p>
<h2 id="Elements">Elements</h2>
<p>The following elements can use the <code>paint-order</code> attribute:</p>
<ul>
  <li><a href="/en/SVG/Element#Shape" title="en/SVG/Element#Shape">Shape elements</a>&nbsp;»</li>
  <li><a href="/en/SVG/Element#TextContent" title="en/SVG/Element#TextContent">Text content elements</a>&nbsp;»</li>
</ul>
Revert to this revision