files/en-us/web/svg/reference/element/pattern/index.md
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 {{SVGAttr("fill")}} and/or {{SVGAttr("stroke")}} attributes on other graphics elements to fill or stroke those elements with the referenced pattern.
{{svginfo}}
{{SVGAttr("height")}}
0; Animatable: yes{{SVGAttr("href")}}
<pattern> attributes.
Value type: <URL>; Default value: none; Animatable: yes{{SVGAttr("patternContentUnits")}}
: This 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
viewBoxattribute is specified on the<pattern>element.
{{SVGAttr("patternTransform")}}
{{SVGAttr("patternUnits")}}
x, y, width, and height.
Value type: userSpaceOnUse | objectBoundingBox; Default value: objectBoundingBox; Animatable: yes{{SVGAttr("preserveAspectRatio")}}
none | xMinYMin | xMidYMin | xMaxYMin | xMinYMid | xMidYMid | xMaxYMid | xMinYMax | xMidYMax | xMaxYMax) (meet | slice)?; Default value: xMidYMid meet; Animatable: yes{{SVGAttr("viewBox")}}
{{SVGAttr("width")}}
0; Animatable: yes{{SVGAttr("x")}}
0; Animatable: yes{{SVGAttr("xlink:href")}} {{deprecated_inline}}
: 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 bothhrefandxlink:hrefare set,xlink:hrefwill be ignored and onlyhrefwill be used.
{{SVGAttr("y")}}
0; Animatable: yesThis element implements the {{domxref("SVGPatternElement")}} interface.
html,
body,
svg {
height: 100%;
}
<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>
{{EmbedLiveSample('Examples', 150, '100%')}}
{{Specifications}}
{{Compat}}