{"id":18258,"date":"2018-11-06T09:00:35","date_gmt":"2018-11-06T15:00:35","guid":{"rendered":"https:\/\/getflywheel.com\/?p=18258"},"modified":"2024-10-02T11:08:48","modified_gmt":"2024-10-02T16:08:48","slug":"css-svg-clipping-and-masking-techniques","status":"publish","type":"resource","link":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/","title":{"rendered":"How to Use CSS and SVG Clipping and Masking Techniques"},"content":{"rendered":"\n<p>SVGs are great for working on the web, and clipping and masking allow for some interesting ways to show or hide pieces of your web graphics. Using these techniques also allows for more flexibility with your designs because you do not have to manually make changes and create new images\u2014it\u2019s all done with code. By using a combination of CSS clipping and masking techniques, you will have lots of options for your website graphics.<\/p>\n\n\n\n<p>To help clarify things, masking and clipping are two different ways you can manipulate images with CSS. Let&#8217;s start with clipping.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Clipping Basics<\/h2>\n\n\n\n<p>If you&#8217;ve ever used Photoshop, you are probably already familiar with Clipping Masks. It\u2019s a similar kind of approach. Clipping involves laying a vector shape, like a circle or a triangle, on top of an image or an element. Any part of the image behind the shape will be visible, while everything outside the boundaries of the shape will be hidden.<\/p>\n\n\n\n<p>For example, if a triangle clipping mask is over the top of an image of a forest, you will see the forest image within the triangle shape. The shape&#8217;s boundary is called the clip path, not to be confused with the depreciated <code>clip<\/code> property. You create the clip path by using the <code>clip-path<\/code> property.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/css-svg-clipping-masking-clipping-graphic.jpg\" alt=\"Graphic that shows the progression of an image, an irregular-shaped clip path, and how the image has changed after being clipped\" class=\"wp-image-18288\" \/><\/figure>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Note: Don&#8217;t Try This on Your Live Site<\/h3>\n\n\n\n<p>Remember: You should never change the code directly on your site, to ensure nothing breaks. Our free local development app, <a rel=\"noreferrer noopener\" href=\"https:\/\/localwp.com\/\" target=\"_blank\">Local<\/a>, will help you set up a test environment where you can safely follow along this tutorial.<\/p>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<h3 class=\"wp-block-heading\">Clipping in Action<\/h3>\n\n\n\n<p>Clips are always vector paths. It can be confusing to understand, but anything outside the path will be hidden, while anything inside the path will be visible. To get a better understanding and to test this out yourself, see the sample on <a href=\"http:\/\/codepen.io\/abbeyjfitzgerald\/pen\/dXZXNr\" target=\"_blank\" rel=\"noopener noreferrer\">CodePen<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/css-svg-clipping-masking-triangle-example.jpg\" alt=\"Screenshot of the sample image on CodePen\" class=\"wp-image-18295\" \/><\/figure>\n\n\n\n<p>Here is a snippet of the HTML structure from the example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]\n\n&amp;amp;amp;amp;lt;svg class=&amp;amp;quot;clip-svg&amp;amp;quot;&amp;amp;amp;amp;gt;\n\t&amp;amp;amp;amp;lt;defs&amp;amp;amp;amp;gt;\n\t\t&amp;amp;amp;amp;lt;clipPath id=&amp;amp;quot;polygon-clip-triangle-equilateral&amp;amp;quot; clipPathUnits=&amp;amp;quot;objectBoundingBox&amp;amp;quot;&amp;amp;amp;amp;gt;\n\t\t\t&amp;amp;amp;amp;lt;polygon points=&amp;amp;quot;0 0.87, 0.5 0, 0.5 0, 1 0.87&amp;amp;quot; \/&amp;amp;amp;amp;gt;\n\t\t&amp;amp;amp;amp;lt;\/clipPath&amp;amp;amp;amp;gt;\n\t&amp;amp;amp;amp;lt;\/defs&amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;lt;\/svg&amp;amp;amp;amp;gt;\n\n[\/html]<\/pre>\n\n\n\n<p>This is the CSS to make the clipping happen:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\n.polygon-clip-triangle-equilateral {\n\t-webkit-clip-path: polygon(0% 87%, 50% 0%, 50% 0%, 100% 87%);\n\tclip-path: polygon(0% 87%, 50% 0%, 50% 0%, 100% 87%);\n\t-webkit-clip-path: url(&amp;amp;quot;#polygon-clip-triangle-equilateral&amp;amp;quot;);\n\tclip-path: url(&amp;amp;quot;#polygon-clip-triangle-equilateral&amp;amp;quot;);\n}\n\n[\/css]<\/pre>\n\n\n\n<p>You can see where the <code>clipPath<\/code> id is being referenced in the HTML and how it uses the <code>clip-path<\/code> URL to do the clipping.<\/p>\n\n\n\n<p><strong>Clippy Tool<\/strong><\/p>\n\n\n\n<p><a href=\"http:\/\/bennettfeely.com\/clippy\/\" target=\"_blank\" rel=\"noopener noreferrer\">Clippy<\/a> is a great tool to generate CSS clip paths. There are a wide variety of starter shapes and sizes that can be customized.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/css-svg-clipping-masking-clippy.png\" alt=\"screenshot illustrating a clip path of a 7-sided shape\" class=\"wp-image-18289\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Masking Basics<\/h2>\n\n\n\n<p>Masking is done using a PNG image, CSS gradient, or an SVG element to hide part of an image or another element on the page. We will be focusing on SVG graphics, but keep in mind this can be done with other image types or styles.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Mask Property and Mask Element<\/h3>\n\n\n\n<p>Just a refresher to help visualize, it\u2019s important to keep in mind that the masked element is the \u201coriginal\u201d (before mask is applied) image. You may not want to see the whole image, so hiding parts of it is done with the CSS <code>mask<\/code> property. The <code>mask<\/code> is the CSS shorthand for a group of individual properties, which we\u2019ll dive into in a second. The SVG <code>&lt;mask&gt;<\/code> element is used inside an SVG graphic to add masking effects. In this example, the mask is a circle and there is also a gradient applied.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using the SVG Mask Element on an SVG Graphic<\/h3>\n\n\n\n<p>To get a feel for the SVG <code>&lt;mask&gt;<\/code> we will be masking with an SVG graphic.<\/p>\n\n\n\n<p>It might be a bit complex at a first glance, but it all works together to mask the underlying image. We have an actual image as a background, so where does the SVG come into play? Unlike the clipping examples, this background image is technically inside of an SVG element. We\u2019ll use CSS to apply this mask to the image. Properties will come from the SVG mask element, and we\u2019ll give it the id of <code>masked-element<\/code> in our CSS.<\/p>\n\n\n\n<p>To see this in &nbsp;action, check out this <a href=\"http:\/\/codepen.io\/abbeyjfitzgerald\/pen\/mELOpy\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen sample<\/a>. Here\u2019s the working code for the masked SVG graphic:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]\n\n&amp;amp;amp;amp;lt;svg class=&amp;amp;quot;masked-element&amp;amp;quot; width=&amp;amp;quot;300&amp;amp;quot; height=&amp;amp;quot;300&amp;amp;quot; viewBox=&amp;amp;quot;0 0 300 300&amp;amp;quot;&amp;amp;amp;amp;gt;\n\t&amp;amp;amp;amp;lt;image xlink:href=&amp;amp;quot;image link&amp;amp;quot; width=&amp;amp;quot;300px&amp;amp;quot; height=&amp;amp;quot;300px&amp;amp;quot; \/&amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;lt;\/svg&amp;amp;amp;amp;gt;\n\n[\/html]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter wp-image-18290 size-full\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/css-svg-clipping-masking-masked-outline.png\" alt=\"screenshot showing the boundaries for the masked element\" class=\"wp-image-18290\" \/><figcaption class=\"wp-element-caption\">if you go to the Inspector, you can see the boundaries for the masked element. The circular shape is created with a mask.<\/figcaption><\/figure>\n\n\n\n<p>With this CSS, we are specifying where to find the mask. It will look for the ID of <code>#mask-this:<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\/* Here\u2019s the CSS for masking *\/\n.masked-element image {\n  mask: url(#mask1);\n}\n\n[\/css]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/updated-css-svg-clipping-masking-svg-mask-1024x472.png\" alt=\"a blue rectangle, in the middle sits a circular image of a forest. Text on image reads: This is a SVG Mask on a SVG Element. SVG Mask on SVG Element. Currently Works in Webkit, Firefox, and IE\" class=\"wp-image-25161\" \/><\/figure>\n\n\n\n<p>Notice a gradient in the circle shape? A gradient has been applied, as well as setting the circle shape for the mask.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]\n\n&amp;amp;amp;amp;lt;svg class=&amp;amp;quot;svg-mask&amp;amp;quot;&amp;amp;amp;amp;gt;\n \t&amp;amp;amp;amp;lt;defs&amp;amp;amp;amp;gt;\n \t\t&amp;amp;amp;amp;lt;mask id=&amp;amp;quot;mask1&amp;amp;quot; maskUnits=&amp;amp;quot;objectBoundingBox&amp;amp;quot; maskContentUnits=&amp;amp;quot;objectBoundingBox&amp;amp;quot;&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;linearGradient id=&amp;amp;quot;grad&amp;amp;quot; gradientUnits=&amp;amp;quot;objectBoundingBox&amp;amp;quot; x2=&amp;amp;quot;0&amp;amp;quot; y2=&amp;amp;quot;1&amp;amp;quot;&amp;amp;amp;amp;gt;\n      &amp;amp;amp;amp;lt;stop stop-color=&amp;amp;quot;white&amp;amp;quot; offset=&amp;amp;quot;0&amp;amp;quot;\/&amp;amp;amp;amp;gt;\n      &amp;amp;amp;amp;lt;stop stop-color=&amp;amp;quot;green&amp;amp;quot; stop-opacity=&amp;amp;quot;0&amp;amp;quot; offset=&amp;amp;quot;1&amp;amp;quot;\/&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;\/linearGradient&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;circle cx=&amp;amp;quot;0.50&amp;amp;quot; cy=&amp;amp;quot;0.50&amp;amp;quot; r=&amp;amp;quot;0.50&amp;amp;quot; id=&amp;amp;quot;circle&amp;amp;quot; fill=&amp;amp;quot;url(#grad)&amp;amp;quot;\/&amp;amp;amp;amp;gt;\n  \t&amp;amp;amp;amp;lt;\/mask&amp;amp;amp;amp;gt;\n \t&amp;amp;amp;amp;lt;\/defs&amp;amp;amp;amp;gt;\n&amp;amp;amp;amp;lt;\/svg&amp;amp;amp;amp;gt;\n\n[\/html]<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">SVG Text Masking<\/h2>\n\n\n\n<p>Text masking can do some pretty cool things, such as showing an image through a text block. The good news is that a text element can be used inside of an SVG mask. As browser support increases in the future, this could be a really interesting way to combine images and typography.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/css-svg-clipping-masking-text-mask.png\" alt=\"an image of a forest with a text overlay that reads: My Text SVG Masking with SVG Text and Mask Elements: displays in Webkit, Firefox, and IE\" class=\"wp-image-18294\" \/><\/figure>\n\n\n\n<p>Here\u2019s a basic explanation of what is going on. There is an SVG text element inside the SVG mask. We\u2019ve specified the RGB value for white, which creates the oval area around the masked text. Anything behind the oval area shows through the text, giving a cut-out feel.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[html]\n\n&amp;amp;amp;amp;lt;div class=&amp;amp;quot;text-wrap&amp;amp;quot;&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;svg class=&amp;amp;quot;text-demo&amp;amp;quot; viewBox=&amp;amp;quot;0 0 600 400&amp;amp;quot; width=&amp;amp;quot;600&amp;amp;quot; height=&amp;amp;quot;400&amp;amp;quot;&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;defs&amp;amp;amp;amp;gt;\n      &amp;amp;amp;amp;lt;mask id=&amp;amp;quot;myMask&amp;amp;quot;&amp;amp;amp;amp;gt;\n        &amp;amp;amp;amp;lt;rect width=&amp;amp;quot;100%&amp;amp;quot; height=&amp;amp;quot;100%&amp;amp;quot; fill=&amp;amp;quot;#fff&amp;amp;quot; \/&amp;amp;amp;amp;gt;\n        &amp;amp;amp;amp;lt;text x=&amp;amp;quot;50&amp;amp;quot; y=&amp;amp;quot;200&amp;amp;quot; id=&amp;amp;quot;myText&amp;amp;quot;&amp;amp;amp;amp;gt;My Text&amp;amp;amp;amp;lt;\/text&amp;amp;amp;amp;gt;\n        &amp;amp;amp;amp;lt;text x=&amp;amp;quot;125&amp;amp;quot; y=&amp;amp;quot;293&amp;amp;quot; id=&amp;amp;quot;mySubtext&amp;amp;quot;&amp;amp;amp;amp;gt;SVG&amp;amp;amp;amp;lt;\/text&amp;amp;amp;amp;gt;\n      &amp;amp;amp;amp;lt;\/mask&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;\/defs&amp;amp;amp;amp;gt;\n    &amp;amp;amp;amp;lt;ellipse class=&amp;amp;quot;masked&amp;amp;quot; cx=&amp;amp;quot;300&amp;amp;quot; cy=&amp;amp;quot;200&amp;amp;quot; rx=&amp;amp;quot;300&amp;amp;quot; ry=&amp;amp;quot;150&amp;amp;quot; fill=&amp;amp;quot;rgba(255, 255, 255, 0.8)&amp;amp;quot; \/&amp;amp;amp;amp;gt;\n  &amp;amp;amp;amp;lt;\/svg&amp;amp;amp;amp;gt;\n  &amp;amp;amp;amp;lt;\/div&amp;amp;amp;amp;gt;\n\n[\/html]<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\n\/* Here\u2019s the CSS for text element *\/\n#myText {\nfont-size: 125px;\nfont-style: bold;\nfill: #000;\n}\n\n\/* Here\u2019s the CSS for masking *\/\n.masked {\nmask: url(&amp;amp;quot;#myMask&amp;amp;quot;);\n}\n\n[\/css]<\/pre>\n\n\n\n<p>To fully understand, it\u2019s helpful to play around and experiment with the code. Try changing colors, changing text, and adjusting sizes in this&nbsp;<a href=\"http:\/\/codepen.io\/abbeyjfitzgerald\/pen\/jAxwOk\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Mask-Image Property<\/h3>\n\n\n\n<p>An image can be declared and the <code>mask-image<\/code> can be set to a URL value. The <code>mask-image<\/code> can be a PNG, SVG, or a reference to an SVG <code>mask<\/code> element, like I demonstrated in the previous example.<\/p>\n\n\n\n<p>Because masking is used to partially or fully hide portions of an object or element, first you\u2019ll want an image link to a file for the element that is going to be masked. Here\u2019s what that image looks like. It\u2019s colorful to make it very apparent which part the mask is showing and hiding.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\n&amp;amp;amp;amp;lt;img class=&amp;amp;quot;mask-img example-mask&amp;amp;quot; src=&amp;amp;quot;https:\/\/linktoimage.com\/img\/image-example.jpg&amp;amp;quot; alt=&amp;amp;quot;Masked image&amp;amp;quot;&amp;amp;amp;amp;gt;\n\n[\/css]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/original-image.png\" alt=\"an abstract image with lots of overlapping colors\" class=\"wp-image-25159\" \/><\/figure>\n\n\n\n<p>So far there\u2019s been a lot of SVG code, but this example is slightly different since there is going to be a raster image masked with an SVG.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\n.example-mask {\n  mask-image: url(https:\/\/linktoimage.com\/browser-icon-01.svg);\n  webkit-mask-image: url(https:\/\/linktoimage.com\/browser-icon-01.svg);\n  mask-mode: alpha;\n  webkit-mask-mode: alpha;\n  mask-repeat: no-repeat;\n  webkit-mask-repeat: no-repeat;\n  mask-size: 200px;\n  webkit-mask-size: 200px;\n  mask-position: center;\n  webkit-mask-position: center;\n}\n\n[\/css]<\/pre>\n\n\n\n<p>The <code>mask-image<\/code> property is where the mask shape will be declared. In this case, the mask image is an SVG graphic. Having the URL link included is how the mask is built.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/original-svg-and-mask.png\" alt=\"an svg graphic in black, and the same graphic that's full of abstract color\" class=\"wp-image-25158\" \/><\/figure>\n\n\n\n<p>Here it is on <a href=\"https:\/\/codepen.io\/abbeyjfitzgerald\/full\/MEGbQO\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Combining Multiple Mask Images<\/h3>\n\n\n\n<p>Just when you thought masking couldn\u2019t get any better, there is the option to set more than one mask image layer. All you need to do is add two URL values (or more if you\u2019re feeling ambitious) separated by a comma.<\/p>\n\n\n\n<p>To expand on the simple mask from above, there will be an arrow added to the original graphic. Here\u2019s how two masks are combined.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\n.combined-mask {\n   mask-image: url(https:\/\/linktoimage.com\/arrow-01.svg), url(https:\/\/linktoimage.com\/browser-icon-01.svg);\n  webkit-mask-image: url(https:\/\/linktoimage.com\/arrow-01.svg), url(https:\/\/linktoimage.com\/browser-icon-01.svg);\n}\n\n[\/css]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/combined-mask.png\" alt=\"a different svg graphic with lots of abstract color\" class=\"wp-image-25157\" \/><\/figure>\n\n\n\n<p>All you have to do is add the two values (with a comma) and now there are two combined masks, making the masking possibilities endless.<\/p>\n\n\n\n<p>Here it is on <a href=\"https:\/\/codepen.io\/abbeyjfitzgerald\/full\/MEGbQO\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Create a Simple Gradient with <code>mask-image<\/code><\/h3>\n\n\n\n<p>Not all masks have to be a complex shape. Sometimes it\u2019s not a particular image that is the mask, but rather a simple mask like a gradient. If you\u2019re looking for a quick way to achieve this, the <code>mask-image<\/code> property is an option, which is pretty easy to implement.<\/p>\n\n\n\n<p>In this example, there was a class applied to a gradient set as the <code>mask-image<\/code> property. With this simple declaration, it was easy to create a gradient mask on the image.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\nmask-image: linear-gradient(black, white, transparent);\n-webkit-mask-image: linear-gradient(black, white, transparent);\n\n[\/css]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/gradient-mask.png\" alt=\"the same abstract image from above with lots of overlapping colors\" class=\"wp-image-25155\" \/><\/figure>\n\n\n\n<p>See this on <a href=\"https:\/\/codepen.io\/abbeyjfitzgerald\/pen\/xXJxGy\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The Mask-Repeat Property<\/h3>\n\n\n\n<p>Once you\u2019ve created one mask, it\u2019s pretty easy to make more. This really comes in handy if you\u2019re looking to make a custom pattern. The mask-repeat property allows for repetition of the mask. If you\u2019ve ever made a tiled background before, this is similar to that.<\/p>\n\n\n\n<p>There are a few important things to keep in mind, like sizing and the type of mask-repeat that needs to be declared so the perfect pattern is created.<\/p>\n\n\n\n<p>The <code>mask-size<\/code> is pretty easy to visualize, especially with the set pixel value here.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[css]\n\nmask-size: 200px;\nwebkit-mask-size: 200px;\n\n[\/css]<\/pre>\n\n\n\n<figure class=\"wp-block-image aligncenter\"><img decoding=\"async\" src=\"https:\/\/getflywheel-images.s3.us-east-2.amazonaws.com\/uploads\/2016\/08\/mask-repeat.png\" alt=\"the abstract image from above, but instead of being the solid image, multiple repeated outlines fill the space and the abstract background colors them in\" class=\"wp-image-25156\" \/><\/figure>\n\n\n\n<p>There are a few more mask-repeat options if you\u2019re looking for a different effect for the pattern:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>repeat-x<\/code> repeats along the x coordinate.<\/li>\n\n\n\n<li><code>Repeat-y<\/code> repeats down the y coordinate.<\/li>\n\n\n\n<li><code>space<\/code> repeats and spreads out in the available area.<\/li>\n\n\n\n<li><code>round<\/code> repeats a number of times across the available area (scaling will help it fill the space if needed)<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Browser Support<\/h2>\n\n\n\n<p>Before committing to this new way of working with graphics, it\u2019s important to note that browser support is not consistent with clipping and masking. Clipping is more supported than masking, but Internet Explorer does not fully support clipping. <\/p>\n\n\n\n<p>Current browser support for CSS masks is also fairly limited, so it\u2019s suggested to be used as an enhancement on a few decorative elements. That way, if it is not supported by the user\u2019s browser, it does not affect the content viewing experience.<\/p>\n\n\n\n<p>To test things out and see if your masks and clippings are supported, we\u2019d recommend making a <a href=\"https:\/\/jsfiddle.net\/\" target=\"_blank\" rel=\"noopener noreferrer\">JSFiddle<\/a> or <a href=\"http:\/\/codepen.io\/\" target=\"_blank\" rel=\"noopener noreferrer\">Codepen<\/a> and then trying it in different browsers. Browser support has increased in the recent years, and it will eventually get to a point where it will be fully-supported. <\/p>\n\n\n\n<p>Don\u2019t let the limitations get you down\u2014it\u2019s always good to be ahead of the game and once support is more mainstream, you will know exactly how to revolutionize your graphics. When in doubt, be sure to reference the trusted <a href=\"http:\/\/caniuse.com\/#feat=css-masks\" target=\"_blank\" rel=\"noopener noreferrer\">Can I Use<\/a>.<\/p>\n\n\n\n<hr class=\"wp-block-separator aligncenter has-alpha-channel-opacity\" \/>\n\n\n\n<p>After experimenting with these examples, this should provide a good introduction to masking and clipping. Although browser support is limited at this time, this will likely become a mainstream practice in the future. <\/p>\n\n\n\n<p>It\u2019s always fun to think about how these techniques can be used to create interesting visuals. The future of web graphics will make us less dependent on image editors and allow for more effective ways to create and modify imagery directly in the browser.<\/p>\n\n\n\n<p>When you want to give all the hard work you&#8217;ve put in on your sites truly shine, make sure you&#8217;re choosing the best possible <a href=\"https:\/\/wpengine.com\/wordpress-hosting\/\" target=\"_blank\" rel=\"noreferrer noopener\">hosting for your WordPress site<\/a> with WP Engine!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SVGs are great for working on the web, and clipping and masking allow for some interesting ways to show or hide pieces of your web graphics. Using these techniques also allows for more flexibility with your designs because you do not have to manually make changes and create new images\u2014it\u2019s all done with code. By<span class=\"tile__ellipses\">&hellip;<\/span><span class=\"tile__ellipses--animated\"><\/span><\/p>\n","protected":false},"author":1,"featured_media":147481,"template":"","resource-topic":[1396,912],"resource-role":[1397,896],"resource-type":[916],"class_list":["post-18258","resource","type-resource","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to Use CSS and SVG Clipping and Masking Techniques | WP Engine<\/title>\n<meta name=\"description\" content=\"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.\" \/>\n<meta name=\"robots\" content=\"noindex, follow\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to Use CSS and SVG Clipping and Masking Techniques | WP Engine\" \/>\n<meta property=\"og:description\" content=\"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/\" \/>\n<meta property=\"og:site_name\" content=\"WP Engine\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/wpengine\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-02T16:08:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2018\/11\/clipping-header.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1100\" \/>\n\t<meta property=\"og:image:height\" content=\"500\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@wpengine\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"11 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/\",\"url\":\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/\",\"name\":\"How to Use CSS and SVG Clipping and Masking Techniques | WP Engine\",\"isPartOf\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\"},\"datePublished\":\"2018-11-06T15:00:35+00:00\",\"dateModified\":\"2024-10-02T16:08:48+00:00\",\"description\":\"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.\",\"breadcrumb\":{\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/wpengine.com\/case-studies\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Resources\",\"item\":\"https:\/\/wpengine.com\/case-studies\/resources\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"How to Use CSS and SVG Clipping and Masking Techniques\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#website\",\"url\":\"https:\/\/wpengine.com\/case-studies\/\",\"name\":\"WP Engine\",\"description\":\"Managed Hosting for WordPress\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085\",\"name\":\"WP Engine\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g\",\"caption\":\"WP Engine\"},\"sameAs\":[\"https:\/\/wpengine.com\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to Use CSS and SVG Clipping and Masking Techniques | WP Engine","description":"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.","robots":{"index":"noindex","follow":"follow"},"og_locale":"en_US","og_type":"article","og_title":"How to Use CSS and SVG Clipping and Masking Techniques | WP Engine","og_description":"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.","og_url":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/","og_site_name":"WP Engine","article_publisher":"https:\/\/www.facebook.com\/wpengine","article_modified_time":"2024-10-02T16:08:48+00:00","og_image":[{"width":1100,"height":500,"url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2018\/11\/clipping-header.png","type":"image\/png"}],"twitter_card":"summary_large_image","twitter_site":"@wpengine","twitter_misc":{"Est. reading time":"11 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/","url":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/","name":"How to Use CSS and SVG Clipping and Masking Techniques | WP Engine","isPartOf":{"@id":"https:\/\/wpengine.com\/case-studies\/#website"},"datePublished":"2018-11-06T15:00:35+00:00","dateModified":"2024-10-02T16:08:48+00:00","description":"Explore various CSS and SVG clipping and masking techniques to create flexible and visually engaging web graphics with step-by-step examples and best practices.","breadcrumb":{"@id":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/wpengine.com\/case-studies\/resources\/css-svg-clipping-and-masking-techniques\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/wpengine.com\/case-studies\/"},{"@type":"ListItem","position":2,"name":"Resources","item":"https:\/\/wpengine.com\/case-studies\/resources\/"},{"@type":"ListItem","position":3,"name":"How to Use CSS and SVG Clipping and Masking Techniques"}]},{"@type":"WebSite","@id":"https:\/\/wpengine.com\/case-studies\/#website","url":"https:\/\/wpengine.com\/case-studies\/","name":"WP Engine","description":"Managed Hosting for WordPress","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/wpengine.com\/case-studies\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/f5301455463371a10d1fc290e9ad0085","name":"WP Engine","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/wpengine.com\/case-studies\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/d8770fe9625ca7c4601f13d9d0ab86565a6dac8cd6a77bfe2ada6d83c6837870?s=96&d=mm&r=g","caption":"WP Engine"},"sameAs":["https:\/\/wpengine.com"]}]}},"acf":[],"grid_image_url":"https:\/\/wpengine.com\/case-studies\/wp-content\/uploads\/2018\/11\/clipping-grid.png","media-type":{"term_id":916,"name":"Article","slug":"article"},"role":"<strong>Roles:<\/strong> Designer, Developer","topic":"<strong>Topics:<\/strong> Design, Performance","_links":{"self":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource\/18258","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource"}],"about":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/types\/resource"}],"author":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/users\/1"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media\/147481"}],"wp:attachment":[{"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/media?parent=18258"}],"wp:term":[{"taxonomy":"resource-topic","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-topic?post=18258"},{"taxonomy":"resource-role","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-role?post=18258"},{"taxonomy":"resource-type","embeddable":true,"href":"https:\/\/wpengine.com\/case-studies\/wp-json\/wp\/v2\/resource-type?post=18258"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}