The <pattern> 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.
<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>
height0; Animatable: yes
href<pattern> attributes.patternContentUnits<pattern>.userSpaceOnUse|objectBoundingBox; Default value: userSpaceOnUse; Animatable: yes Note: This attribute has no effect if a viewBox attribute is specified on the <pattern> element.
patternTransformpatternUnitsx, y, width and height.userSpaceOnUse|objectBoundingBox; Default value: objectBoundingBox; Animatable: yes
preserveAspectRationone| xMinYMin| xMidYMin| xMaxYMin| xMinYMid| xMidYMid| xMaxYMid| xMinYMax| xMidYMax| xMaxYMax) (meet|slice)? ; Default value: xMidYMid meet; Animatable: yes
viewBoxwidth0; Animatable: yes
x0; Animatable: yes
xlink:href Deprecated since SVG 2
<pattern> attributes.Note: For browsers implementing href, if both href and xlink:href are set, xlink:href will be ignored and only href will be used.
y0; Animatable: yes
id, tabindexclass, stylerequiredExtensions, systemLanguageclip-path, clip-rule, color, color-interpolation, color-rendering, cursor, display, fill, fill-opacity, fill-rule, filter, mask, opacity, pointer-events, shape-rendering, stroke, stroke-dasharray, stroke-dashoffset, stroke-linecap, stroke-linejoin, stroke-miterlimit, stroke-opacity, stroke-width, transform, vector-effect, visibilityxlink:title| Categories | Container element |
|---|---|
| Permitted content | Any number of the following elements, in any order: Animation elements Descriptive elements Shape elements Structural elements Gradient elements <a>, <altGlyphDef>, <clipPath>, <color-profile>, <cursor>, <filter>, <font>, <font-face>, <foreignObject>, <image>, <marker>, <mask>, <pattern>, <script>, <style>, <switch>, <text>, <view>
|
| Specification | Status | Comment |
|---|---|---|
| Scalable Vector Graphics (SVG) 2 The definition of '<pattern>' in that specification. | Candidate Recommendation | |
| Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of '<pattern>' in that specification. | Recommendation | Initial definition |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes | Yes | Yes | Yes | Yes | 3 |
patternUnits |
? | ? | ? | ? | ? | 3 |
patternContentUnits |
? | ? | ? | ? | ? | 3 |
patternTransform |
? | ? | ? | ? | ? | 3 |
x |
Yes | Yes | Yes | Yes | Yes | 3 |
y |
Yes | Yes | Yes | Yes | Yes | 3 |
height |
Yes | Yes | Yes | Yes | Yes | 3 |
width |
Yes | Yes | Yes | Yes | Yes | 3 |
href |
? | ? | ? | ? | ? | ? |
xlink:href
|
Yes | Yes | Yes | Yes | Yes | 3 |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | Yes | Yes | 3 | ? |
patternUnits |
? | ? | ? | ? | ? | 3 | ? |
patternContentUnits |
? | ? | ? | ? | ? | 3 | ? |
patternTransform |
? | ? | ? | ? | ? | 3 | ? |
x |
Yes | Yes | Yes | Yes | Yes | 3 | ? |
y |
Yes | Yes | Yes | Yes | Yes | 3 | ? |
height |
Yes | Yes | Yes | Yes | Yes | 3 | ? |
width |
Yes | Yes | Yes | Yes | Yes | 3 | ? |
href |
? | ? | ? | ? | ? | ? | ? |
xlink:href
|
Yes | Yes | Yes | Yes | Yes | 3 | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/SVG/Element/pattern