This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
* Some parts of this feature may have varying levels of support.
The <pattern> SVG element defines a graphics object which can be redrawn at repeated x- and y-coordinate intervals ("tiled") to cover an area.
The <pattern> is referenced by the fill and/or stroke attributes on other graphics elements to fill or stroke those elements with the referenced pattern.
| Categories | Container element |
|---|---|
| Permitted content | Any number of the following elements, in any order: Animation elements Descriptive elements Gradient elements Shape elements Structural elements <a>, <clipPath>, <filter>, <foreignObject>, <image>, <marker>, <mask>, <script>, <style>, <switch>, <text>, <view>
|
heightThis attribute determines the height of the pattern tile. Value type: <length>; Default value: 0; Animatable: yes
hrefThis attribute reference a template pattern that provides default values for the <pattern> attributes. Value type: <URL>; Default value: none; Animatable: yes
patternContentUnitsThis attribute defines the coordinate system for the contents of the <pattern>. Value type: userSpaceOnUse | objectBoundingBox; Default value: userSpaceOnUse; Animatable: yes
Note: This attribute has no effect if a viewBox attribute is specified on the <pattern> element.
patternTransformThis attribute contains the definition of an optional additional transformation from the pattern coordinate system onto the target coordinate system. Value type: <transform-list>; Default value: identity transform; Animatable: yes
patternUnitsThis attribute defines the coordinate system for attributes x, y, width, and height. Value type: userSpaceOnUse | objectBoundingBox; Default value: objectBoundingBox; Animatable: yes
preserveAspectRatioThis attribute defines how the SVG fragment must be deformed if it is embedded in a container with a different aspect ratio. Value type: (none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid | xMinYMax | xMidYMax | xMaxYMax) (meet | slice)?; Default value: xMidYMid meet; Animatable: yes
viewBoxThis attribute defines the bound of the SVG viewport for the pattern fragment. Value type: <list-of-numbers>; Default value: none; Animatable: yes
widthThis attribute determines the width of the pattern tile. Value type: <length>; Default value: 0; Animatable: yes
xThis attribute determines the x coordinate shift of the pattern tile. Value type: <length>; Default value: 0; Animatable: yes
xlink:href Deprecated
This attribute references a template pattern that provides default values for the <pattern> attributes. Value type: <URL>; Default value: none; Animatable: yes
Note: For browsers implementing href, if both href and xlink:href are set, xlink:href will be ignored and only href will be used.
yThis attribute determines the y coordinate shift of the pattern tile. Value type: <length>; Default value: 0; Animatable: yes
This element implements the SVGPatternElement interface.
<svg viewBox="0 0 230 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="star" viewBox="0,0,10,10" width="10%" height="10%">
<polygon points="0,0 2,5 0,10 5,8 10,10 8,5 10,0 5,2" />
</pattern>
</defs>
<circle cx="50" cy="50" r="50" fill="url(#star)" />
<circle
cx="180"
cy="50"
r="40"
fill="none"
stroke-width="20"
stroke="url(#star)" />
</svg>
| Specification |
|---|
| Scalable Vector Graphics (SVG) 2> # PatternElement> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
pattern |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
height |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
href |
50 | 79 | 3 | 37 | 12.1 | 50 | 4 | 37 | 12.2 | 5.0 | 50 | 12.2 |
patternContentUnits |
1 | 79 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
patternTransform |
1 | 79 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
patternUnits |
1 | 79 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
systemLanguage |
1 | 12 | 12 | 15 | 3 | 18 | 14 | 14 | 3 | 1.0 | 4.4 | 3 |
width |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
x |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
xlink_href |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
y |
1 | 12 | 3 | 15 | 3 | 18 | 4 | 14 | 3 | 1.0 | 4.4 | 3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Reference/Element/pattern