Step 1: Create a pattern
There are dozens of different applications that will allow you to design an SVG pattern. My favorite is Illustrator, so that’s what I’ll be using.![001](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0012.jpg)
![002](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0021.jpg)
![003](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0032.jpg)
![004](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0041.jpg)
![005](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0051.jpg)
![006](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0061.jpg)
![007](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/0071.jpg)
![008](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/008.jpg)
![009](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/009.jpg)
![010](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/010.jpg)
![011](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/011.jpg)
![012](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/012.jpg)
![013](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/013.jpg)
Step 2: Export the pattern
You’ll notice that once you exit the pattern mode the pattern is automatically selected as your fill. All you need to do is draw a shape on the artboard and it will be filled with the pattern. (If for any reason you’ve changed the fill on the shape, you can find your pattern in the swatches panel, apply it like any other fill.) Next, resize your shape so that it covers the whole 300px by 300px artboard.![014](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/014.jpg)
![015](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/015.jpg)
![016](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/016.jpg)
Step 3: Edit the SVG pattern
Open up the .svg file in a text editor. I’m using Sublime Text, but you can use Notepad, Dreamweaver, or whatever you code HTML in. Open up the same file in a browser so you can preview any changes you make to the code.![017](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/017.jpg)
![018](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/018.jpg)
![019](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/019.jpg)
![020](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/020.jpg)
![021](https://www.webdesignerdepot.com/cdn-origin/uploads/2014/12/021.jpg)
<?xml version="1.0" encoding="utf-8"?> <!-- Generator: Adobe Illustrator 18.1.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "https://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" id="Layer_1" xmlns="https://www.w3.org/2000/svg" xmlns:xlink="https://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 100% 100%" enable-background="new 0 0 300 300" xml:space="preserve"> <pattern width="70" height="70" patternUnits="userSpaceOnUse" id="Unnamed_Pattern" viewBox="50 -100 100 100" overflow="visible"> <g> <polygon fill="#c4e0d3" points="50,-100 150,-100 150,0 50,0 "/> <g> <polygon fill="#ff6596" points="200,-50 150,-50 130,-25 150,0 200,0 180,-25 "/> </g> <g> <polygon fill="#0299a7" points="100,-50 150,-50 170,-75 150,-100 100,-100 120,-75 "/> <polygon fill="#ff0a5c" points="100,-50 50,-50 30,-25 50,0 100,0 80,-25 "/> </g> <g> <polygon fill="#ff7635" points="0,-50 50,-50 70,-75 50,-100 0,-100 20,-75 "/> </g> </g> </pattern> <rect fill="url(#Unnamed_Pattern)" width="100%" height="100%"/> </svg>That’s perfectly valid, but it’s a little messy (thanks Illustrator). So I’d recommend optimizing it before you use it. There are lots of optimization options available, but Peter Collingridge’s is one of the best, it gives us this final code:
<svg xmlns="https://www.w3.org/2000/svg" version="1.1" id="Layer_1" x="0" y="0" viewBox="0 0 100% 100%" enable-background="new 0 0 300 300" xml:space="preserve"><pattern width="70" height="70" patternUnits="userSpaceOnUse" id="Unnamed_Pattern" viewBox="50 -100 100 100" overflow="visible"><polygon fill="#c4e0d3" points="50 -100 150 -100 150 0 50 0 "/><polygon fill="#ff6596" points="200 -50 150 -50 130 -25 150 0 200 0 180 -25 "/><polygon fill="#0299a7" points="100 -50 150 -50 170 -75 150 -100 100 -100 120 -75 "/><polygon fill="#ff0a5c" points="100 -50 50 -50 30 -25 50 0 100 0 80 -25 "/><polygon fill="#ff7635" points="0 -50 50 -50 70 -75 50 -100 0 -100 20 -75 "/></pattern><rect fill="url(#Unnamed_Pattern)" width="100%" height="100%"/></svg>
Conclusion
Having the ability to export your Illustrator swatches and patterns as SVGs opens up a wealth of possibilities. Not only can you create an SVG pattern, you can edit the file in a matter of minutes, controlling colors, sizes, and how the file itself is rendered in the browser.James George
James George is a Professional Web & Graphic Designer. He owns Design Crawl, a site for graphic designers featuring free vector graphics and templates. He also owns G Squared Studios, which handles web design in Knoxville.
Read Next
15 Best New Fonts, July 2024
Welcome to our monthly roundup of the best fonts we’ve found online in the last four weeks. This month, there are fewer…
By Ben Moss
20 Best New Websites, July 2024
Welcome to July’s round up of websites to inspire you. This month’s collection ranges from the most stripped-back…
Top 7 WordPress Plugins for 2024: Enhance Your Site's Performance
WordPress is a hands-down favorite of website designers and developers. Renowned for its flexibility and ease of use,…
By WDD Staff
Exciting New Tools for Designers, July 2024
Welcome to this July’s collection of tools, gathered from around the web over the past month. We hope you’ll find…
3 Essential Design Trends, July 2024
Add some summer sizzle to your design projects with trendy website elements. Learn what's trending and how to use these…
15 Best New Fonts, June 2024
Welcome to our roundup of the best new fonts we’ve found online in the last month. This month, there are notably fewer…
By Ben Moss
20 Best New Websites, June 2024
Arranging content in an easily accessible way is the backbone of any user-friendly website. A good website will present…
Exciting New Tools for Designers, June 2024
In this month’s roundup of the best tools for web designers and developers, we’ll explore a range of new and noteworthy…
3 Essential Design Trends, June 2024
Summer is off to a fun start with some highly dramatic website design trends showing up in projects. Let's dive in!
15 Best New Fonts, May 2024
In this month’s edition, there are lots of historically-inspired typefaces, more of the growing trend for French…
By Ben Moss
How to Reduce The Carbon Footprint of Your Website
On average, a web page produces 4.61 grams of CO2 for every page view; for whole sites, that amounts to hundreds of KG…
By Simon Sterne
20 Best New Websites, May 2024
Welcome to May’s compilation of the best sites on the web. This month we’re focused on color for younger humans,…