{"id":331684,"date":"2020-12-27T06:42:37","date_gmt":"2020-12-27T14:42:37","guid":{"rendered":"https:\/\/css-tricks.com\/?p=331684"},"modified":"2020-12-27T06:42:40","modified_gmt":"2020-12-27T14:42:40","slug":"clippath-vs-mask","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/clippath-vs-mask\/","title":{"rendered":"clipPath vs. mask"},"content":{"rendered":"\n

These things are so similar, I find it hard to keep them straight. This is a nice little explanation<\/a> from viewBox (what a cool name and URL<\/a>, I hope they keep it up). <\/p>\n\n\n\n

The big thing is that clipPath<\/code> (the element in SVG, as well as clip-path<\/code> in CSS) is vector and when it is applied, whatever you are clipping is either in or out<\/strong>. With a mask, you can also do partial<\/em> transparency, meaning you can use a gradient to, for example, fade out the thing you are masking. So it occurs to me that masks are more powerful, as they can do everything a clip path can do and more. <\/p>\n\n\n\n\n\n\n\n

Sarah has a whole post<\/a> going into this as well. <\/p>\n\n\n\n

What always bends my brain with masks is the idea that they can be luminance<\/code>-style, meaning white is transparent, black is opaque, and everything in between is partially transparent. Or they can be alpha<\/code>-style, where the alpha channel of the pixel is the alpha-ness of the mask. Writing that feels relatively clear, but when you then apply it to an element it feels all reverso and confusing. <\/p>\n","protected":false},"excerpt":{"rendered":"

These things are so similar, I find it hard to keep them straight. This is a nice little explanation from viewBox (what a cool name and URL, I hope they keep it up). The big thing is that clipPath (the element in SVG, as well as clip-path in CSS) is vector and when it is […]<\/p>\n","protected":false},"author":3,"featured_media":331686,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":[]},"categories":[17],"tags":[518,1299,1298],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/css-tricks.com\/wp-content\/uploads\/2020\/12\/Screen-Shot-2020-12-26-at-1.54.16-PM.png?fit=1190%2C482&ssl=1","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/331684"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=331684"}],"version-history":[{"count":1,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/331684\/revisions"}],"predecessor-version":[{"id":331687,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/331684\/revisions\/331687"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media\/331686"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=331684"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=331684"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=331684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}