> [Site index](https://perfectvector.com/llms.txt) — available pages and descriptions.

# SVG Gradient Hard Stops for Sharp Color Boundaries

> Create a hard stop in an SVG gradient with two colors at the same offset. Verify a sharp boundary, move it, and decide when to use separate paths.

Source: https://perfectvector.com/blog/svg-gradient-hard-stops

Language: en
Author: Irene Kim
Published: 2026-11-26T08:00:00+09:00

To make a **hard stop in an SVG gradient**, put two different colors at the same `offset`. Put the outgoing color first and the incoming color second. Use the first color at the start of the gradient and the second at the end if you want two solid bands. The shared offset marks where one color gives way to the other. [SVG 2 rules for gradient stops](https://www.w3.org/TR/SVG2/pservers.html#StopNotes)

A **hard stop** is an abrupt change from one color to another inside a gradient. A stop's **offset** marks its position along the gradient line. A hard stop at 60% on a horizontal bar is handy when the bar's fill needs to show a threshold while its outline stays a single shape.

## Make a two-color SVG with a boundary at 60%

You need a text editor and an SVG viewer. Save this as `threshold.svg` and open it. The first row has two stops at the same position. In the second row, teal stops at 55% and the orange stop starts at 65%, leaving room for a blend.

```svg
<svg xmlns="http://www.w3.org/2000/svg" width="200" height="86" viewBox="0 0 200 86">
  <defs>
    <linearGradient id="hard" x1="0%" y1="0%" x2="100%" y2="0%">
      <stop offset="0%" stop-color="#137872"/>
      <stop offset="60%" stop-color="#137872"/>
      <stop offset="60%" stop-color="#f39a52"/>
      <stop offset="100%" stop-color="#f39a52"/>
    </linearGradient>
    <linearGradient id="soft" x1="0%" y1="0%" x2="100%" y2="0%">
      <stop offset="0%" stop-color="#137872"/>
      <stop offset="55%" stop-color="#137872"/>
      <stop offset="65%" stop-color="#f39a52"/>
      <stop offset="100%" stop-color="#f39a52"/>
    </linearGradient>
  </defs>
  <rect width="200" height="34" rx="9" fill="url(#hard)"/>
  <rect y="52" width="200" height="34" rx="9" fill="url(#soft)"/>
</svg>
```

1. Keep both middle offsets at `60%` in the first gradient. The teal reaches the boundary and the orange begins there.
2. Render the file at its original width of 200 pixels. Inspect the center of the bar near x = 120, away from rounded corners.
3. Move both 60% stops to 45%. Reopen the file. The hard boundary should move from x = 120 to x = 90 at the same output width.

In our resvg render, the hard-stop row changed from **#137872 at pixel x = 119** to **#F39A52 at x = 120**. The matching pixels in the soft row were two intermediate colors. After changing both hard stops to 45%, the same pure colors met between pixels 89 and 90.

![A sharp teal-to-orange SVG boundary compared with a soft color transition across the same bar](https://perfectvector.com/blog/svg-gradient-hard-stops/workflow-proof.webp)

*Both bars have the same width and rounded outline. The upper boundary uses two 60% stops. The lower bar blends between 55% and 65%.*

## Move the boundary without changing the shape

When the gradient uses the default `objectBoundingBox` units, the coordinates are relative to the shape's bounding box. The 60% boundary follows the width of each object. If you need the same vertical color boundary across several shapes in one artwork, use `gradientUnits="userSpaceOnUse"` and set the gradient line in a common coordinate system. The [SVG gradient units guide](https://perfectvector.com/blog/svg-gradient-units) shows how to check that alignment. [SVG 2 object bounding box units](https://www.w3.org/TR/SVG2/coords.html#ObjectBoundingBoxUnits)

A gradient controls the paint inside one shape. If the teal and orange areas need to become separate objects for recoloring or production, use two paths. A hard stop works well for a display graphic that should retain a single outline. When a visible line or label conveys the threshold, a reader can still identify it without relying on the color change alone. [WCAG use of color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html)

## Troubleshoot a soft or misplaced color edge

If you see a band of mixed color, check that the middle offsets are identical. Check their source order too. SVG uses the later stop's color at the shared offset, and the stop positions should be in ascending or equal order. If the edge is hard but points the wrong way, check the start and end coordinates of the gradient. For a radial version, see [how to place the focus of an SVG radial gradient](https://perfectvector.com/blog/svg-radial-gradient-focus).

At a display size where the edge lands between pixels, you may see a narrow transition from rendering or resampling. Inspect the saved stop values and the bar at its intended size before changing the gradient.

## FAQ

### Can two SVG gradient stops have the same offset?

Yes. Place adjacent stops with different colors at the same offset to create an abrupt change. The later stop controls the exact shared position.

### How do I make three solid color bands in SVG?

Use a pair of equal-offset stops at each boundary. To make boundaries at 30% and 70%, pair the first and second colors at 30%, and the second and third colors at 70%.

### Can I select the two colors as separate shapes?

No. The bands are one fill on one SVG shape. Use separate paths if each color needs its own selectable geometry.

## Start with a clean outline

PerfectVector can turn a flat raster silhouette into an editable SVG outline. The gradient is a paint decision you make after checking that outline.

If you only have the bitmap, [trace the silhouette into editable paths](https://perfectvector.com/image-to-vector). Inspect the outer contour and openings, then apply the hard-stop fill to the path you want to keep.

## Sources

1. [W3C SVG 2 — Notes on gradient stops](https://www.w3.org/TR/SVG2/pservers.html#StopNotes) — Consecutive stops, offsets, and equal-offset ordering.
2. [W3C SVG 2 — Object bounding box units](https://www.w3.org/TR/SVG2/coords.html#ObjectBoundingBoxUnits) — Coordinate systems for paint servers.
3. [W3C Understanding WCAG 2.2 — Use of color](https://www.w3.org/WAI/WCAG22/Understanding/use-of-color.html) — Additional cues for information conveyed through color.

## Explore

- [Read the HTML article](https://perfectvector.com/blog/svg-gradient-hard-stops)
- [SVG Gradient Along a Path: Check Color Around a Bend](https://perfectvector.com/blog/svg-gradient-curved-stroke.md)
- [SVG feImage: Fit, Crop, or Stretch a Filter Image](https://perfectvector.com/blog/svg-feimage-aspect-ratio.md)
- [Product facts](https://perfectvector.com/product-facts.md)
- [FAQ](https://perfectvector.com/faq.md)
- [Pricing and credits](https://perfectvector.com/pricing.md)
