X.X.X. The ‘bbox-rendering’ property

Name: bbox-rendering
Value: [fill] [stroke] [markers]
Initial: fill
Applies to: graphics elements
Inherited: yes
Percentages: N/A
Media: visual
Computed value: as specified
Animatable: no

Controls the extent of the bounding box used when any paint server, clip, mask, or filter, specifies a units scale of "objectBoundingBox".

The values correspond to the values in the SVGBoundingBoxOptions parameter to the getBBox() function. fill (the default) means that the fill is included in the bounding box. stroke means that the stroke shape is included. markers means that bounds of any rendered markers are to be included in the bounding box.

Include clipped in the list of possible values? It would need to be ignored when clipPathUntits="objectBoundingBox" though.

The following example shows how the ‘bbox-rendering’ property can be used to control the extent of the bounding box.

<svg width="500" height="350">
    
    <defs>
        <linearGradient id="gradient" gradientUnits="objectBoundingBox"
                        x2="1" y2="1" spreadMethod="repeat">
            <stop offset="0" stop-color="blue"/>
            <stop offset="1" stop-color="green"/>
        </linearGradient>
    </defs>

    <rect x="50" y="100" width="150" height="150" fill="none"
    stroke-width="40" stroke="url(#gradient)"/>

    <rect x="300" y="100" width="150" height="150" fill="none"
    stroke-width="40" stroke="url(#gradient)" bbox-rendering="stroke" />

</svg>

Linear gradient extends to the bounds of the stroke.