Practical design workflow

Why an SVG Gradient Disappears on a Horizontal or Vertical Line

Two fine graphite lines reach across a low charcoal oval with an amber edge.

You can see the gradient in a test rectangle and still get an empty divider. The SVG can be valid while the straight line’s geometric bounding box gives its paint server no height or width to work with.

Quick answer

A horizontal or vertical SVG line has a geometric bounding box with zero height or zero width. Stroke thickness is excluded from that box. When a gradient uses objectBoundingBox coordinates, the effect can be ignored on that line. Use a nonzero gradient vector in userSpaceOnUse coordinates and test the actual embed.

Fix one straight line in isolation

Use the Trail Index divider in a minimal SVG with a known viewBox. Draw a horizontal line from (12, 30) to (108, 30). A default objectBoundingBox gradient may disappear even with a thick stroke. Keep a filled rectangle with the same paint server as a control: its geometry covers a nonzero area.

Define the intended user-space vector

Set gradientUnits to userSpaceOnUse and use explicit coordinates that follow the desired direction, such as x1=12, y1=30, x2=108, y2=30. For a vertical stroke, vary the endpoints along the y-axis. An explicit fallback color after the URL can help diagnostics. Check the referenced ID, inherited definitions, and any group transform if the fix does not show up.

Review checklist
What you see or checkWhat it means or requiresNext action
Straight horizontal lineObject bounds have zero heightReplace object-bounds coordinates with a horizontal user-space vector.
Straight vertical lineObject bounds have zero widthChoose a vertical user-space vector.
Filled rectangle still takes the gradientPaint server resolves for nondegenerate geometryKeep as the control while changing only the line.
Missing plain stroke tooPossible clipping, styling or geometry issueTest the same line with a plain stroke and visible viewBox.

Try the fictional example in Ciyo

The fictional divider board shows the rectangular control while the fixed line is on a separate overlay.

Import both review images into a separate Ciyo project. Use Select to put the movable comparison overlay beside the original and keep the zoom fixed. The production capture shows those layer placements.

The fictional divider board shows the rectangular control while the fixed line is on a separate overlay.
Initial placement of the fictional review layers in the production Ciyo canvas.

What changed on the production canvas

The visible user-space stroke sits beside the original straight-line example and the filled control.

The visible user-space stroke sits beside the original straight-line example and the filled control.
The revised placement in the same production workspace.

Compare real render targets

Open the original and revised SVG in the actual delivery context. Test an inline SVG and an image element if both are used. Keep viewport dimensions unchanged and include a plain-stroke control so viewBox clipping can be diagnosed separately. Verify the end colors and direction after resizing or embedding the SVG.

Sources

Frequently asked questions

Will a thicker stroke fix the bounding box?

Stroke thickness does not change the geometry used by objectBoundingBox. Change the coordinate system or the actual geometry.

Why did the gradient direction move?

Changing to user space changes which coordinate system defines its stops. Measure endpoints in the relevant user space and account for transformations.

Compare rendered SVG proofs in Ciyo

Bring the original and revised proof to the same canvas and compare them at a shared scale before you sign off.