SVG Patterns

You are Here:

SVG Patterns

The <pattern> SVG element defines a graphics object which can be redrawn at repeated x and y-coordinate intervals ("tiled") to cover an area.

In this example, we will create a chess like pattern by using <pattern> SVG attribute.


HTML Online Editor
<!DOCTYPE html> <html lang="en-US"> <body> <svg width="100%" height="600"> <pattern id="patt" x="0" y="0" width="150" height="150" patternUnits="userSpaceOnUse" > <rect x="0" width="75" height="75" y="0"/> <rect x="75" width="75" height="75" y="75"/> </pattern> <rect x="0" y="0" width="100%" height="100%" fill="url(#patt)" /> </svg> </body> </html>

Attributes Value

heightSpecifies the height of the pattern tile.
hrefSpecifies a template pattern that provides default values for the <pattern> attributes.
patternContentUnitsSpecifies the coordinate system for the contents of the <pattern>.
patternTransformSpecifies the definition of an optional additional transformation from the pattern coordinate system onto the target coordinate system.
patternUnitsSpecifies the coordinate system for attributes x, y, width and height.
preserveAspectRatioSpecifies how the svg fragment must be deformed if it is embedded in a container with a different aspect ratio.
viewBoxSpecifies the bound of the SVG viewport for the pattern fragment.
widthSpecifies the width of the pattern tile.
xSpecifies the x coordinate shift of the pattern tile.
ySpecifies the y coordinate shift of the pattern tile.


Hi Developers, we almost covered 91% of SVG Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in SVG.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author