The SVG <pattern> element defines a small graphic tile that repeats across a shape. Put it in <defs>, give it an id, then paint with fill="url(#id)" or stroke="url(#id)".
Great for dots, grids, and stripes. For smooth color blends, use linear or radial gradients instead.
Baseline · Widely available.
<pattern> paint servers are stable across modern browsers since about July 2015.
Zero tile size hides the pattern.
Default width and height are 0. Always set positive tile dimensions.
Deprecated for new work: xlink:href.
Prefer a full local <pattern> definition, or modern href when you need a template reference.
Note: with viewBox set, patternContentUnits is ignored.
Edge Cases & Pitfalls
Most missing patterns are zero tile size, wrong ids, or unit surprises.
size
width/height must be positive
Defaults are 0. A zero tile never paints.
units
objectBoundingBox can stretch
Default units scale with the shape. Prefer userSpaceOnUse for fixed pixel-like tiles while learning.
id
url(#id) must match
Typos fall back to no pattern fill. Keep ids unique in the document.
defs
Pattern is not painted alone
Nothing shows until a shape references the pattern with fill or strokeurl(#…).
Compatibility
Browser Support
SVG <pattern> is supported in every modern browser.
✓ Baseline · Widely available
SVG <pattern>
Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera support pattern tiles and url(#id) paint. Internet Explorer 9+ supports basic SVG patterns.
97%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet Explorer9+
Supported
<pattern>Widely supported
Bottom line: Safe for production textures and chart fills. Start with userSpaceOnUse and explicit tile sizes for predictable results.
Remember
Key Takeaways
Define a tile in <defs> with an id.
Size: positive width and height.
Apply:fill or strokeurl(#id).
Transform with patternTransform when needed.
One line: tile in <pattern>, paint with url(#id).
UA style
Default CSS Settings
Patterns are paint servers — they have no visible box of their own:
defaults.css
/* Conceptual defaults */
pattern {
/* width/height default to 0 → invisible until set */
/* patternUnits: objectBoundingBox */
/* patternContentUnits: userSpaceOnUse */
}
.shape {
fill: url(#dots);
}
Prefer presentation attributes in these lessons so the paint stays inside the SVG markup.
Frequently Asked Questions
Define a <pattern> in <defs> with an id and tile graphics. Apply it with fill="url(#id)" or stroke="url(#id)" so the tile repeats across the shape.
They set the size of one tile. Default is 0, which draws nothing — always set positive width and height.
It sets the coordinate system for x, y, width, and height. Default objectBoundingBox uses the target shape box; userSpaceOnUse uses absolute SVG units.
Yes. Use stroke="url(#id)" and a large enough stroke-width so the tile is visible along the outline.
Often objectBoundingBox units or a mismatched tile size. Try userSpaceOnUse and tune width/height.
Use patterns for repeating textures and grids. Use linear or radial gradients for smooth color blends.