Close Menu
Soshace Digital Blog

    Subscribe to Updates

    Get The Latest News, Updates, And Amazing Offers

    What's Hot
    Programming

    Angular 2, part 1

    Development

    Enhancing Development Quality Through Effective Code Reviews

    Remote Job

    7 Statistics About Remote Work to Make Your Company Better

    Important Pages:
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Today's Picks:
    • Scaling Success: Monitoring Indexation of Programmatic SEO Content
    • Leveraging Influencers: Key Drivers in New Product Launches
    • How Privacy-First Marketing Will Transform the Industry Landscape
    • The Impact of Social Proof on Thought Leadership Marketing
    • Balancing Value-Driven Content and Promotional Messaging Strategies
    • Top Influencer Marketing Platforms to Explore in 2025
    • Emerging Trends in Marketing Automation and AI Tools for 2023
    • Strategies to Mitigate Duplicate Content in Programmatic SEO
    Wednesday, September 10
    Facebook X (Twitter) Instagram LinkedIn YouTube
    Soshace Digital Blog
    • Home
    • About
    • Services
    • Contact Us
    • Privacy Policy
    • Terms & Conditions
    Services
    • SaaS & Tech

      Maximizing Efficiency: How SaaS Lowers IT Infrastructure Costs

      August 27, 2025

      Navigating Tomorrow: Innovations Shaping the Future of SaaS

      August 27, 2025

      Maximizing Impact: Strategies for SaaS & Technology Marketing

      August 27, 2025
    • AI & Automation

      Enhancing Customer Feedback Analysis Through AI Innovations

      August 27, 2025

      Navigating the Impact of AI on SEO and Search Rankings

      August 27, 2025

      5 Automation Hacks Every Home Service Business Needs to Know

      May 3, 2025
    • Finance & Fintech

      Critical Missteps in Finance Marketing: What to Avoid

      August 27, 2025

      Analyzing Future Fintech Marketing Trends: Insights Ahead

      August 27, 2025

      Navigating the Complex Landscape of Finance and Fintech Marketing

      August 27, 2025
    • Legal & Compliance

      Exploring Thought Leadership’s Impact on Legal Marketing

      August 27, 2025

      Maximizing LinkedIn: Strategies for Legal and Compliance Marketing

      August 27, 2025

      Why Transparency Matters in Legal Advertising Practices

      August 27, 2025
    • Medical Marketing

      Enhancing Online Reputation Management in Hospitals: A Guide

      August 27, 2025

      Analyzing Emerging Trends in Health and Medical Marketing

      August 27, 2025

      Exploring Innovative Content Ideas for Wellness Blogs and Clinics

      August 27, 2025
    • E-commerce & Retail

      Strategic Seasonal Campaign Concepts for Online and Retail Markets

      August 27, 2025

      Emerging Trends in E-commerce and Retail Marketing Strategies

      August 27, 2025

      Maximizing Revenue: The Advantages of Affiliate Marketing for E-Commerce

      August 27, 2025
    • Influencer & Community

      Leveraging Influencers: Key Drivers in New Product Launches

      August 27, 2025

      Top Influencer Marketing Platforms to Explore in 2025

      August 27, 2025

      Key Strategies for Successful Influencer Partnership Negotiations

      August 27, 2025
    • Content & Leadership

      The Impact of Social Proof on Thought Leadership Marketing

      August 27, 2025

      Balancing Value-Driven Content and Promotional Messaging Strategies

      August 27, 2025

      Analyzing Storytelling’s Impact on Content Marketing Effectiveness

      August 27, 2025
    • SEO & Analytics

      Scaling Success: Monitoring Indexation of Programmatic SEO Content

      August 27, 2025

      Strategies to Mitigate Duplicate Content in Programmatic SEO

      August 27, 2025

      Effective Data Visualization Techniques for SEO Reporting

      August 27, 2025
    • Marketing Trends

      How Privacy-First Marketing Will Transform the Industry Landscape

      August 27, 2025

      Emerging Trends in Marketing Automation and AI Tools for 2023

      August 27, 2025

      Maximizing ROI: Key Trends in Paid Social Advertising

      August 27, 2025
    Soshace Digital Blog
    Blog / CSS / Imperative Guide to CSS masking
    CSS

    Imperative Guide to CSS masking

    adeneyeBy adeneyeJanuary 19, 2023Updated:January 31, 2023No Comments4 Mins Read
    Facebook Twitter Pinterest Telegram LinkedIn Tumblr Email Reddit
    Imperative Guide to CSS masking
    Imperative Guide to CSS masking
    Share
    Facebook Twitter LinkedIn Pinterest Email Copy Link
    Imperative Guide to CSS masking
    Imperative Guide to CSS masking

    What is CSS Masking

    Masking in CSS is the process of hiding or partially hiding images or graphical elements. It is a graphical operation that hides a partial portion of an image or object. It allows you to use an image as a mask layer with different opacity levels. This implies that you can use an Image, an SVG, or a gradient as your mask to create a beautiful visual effect.

    In CSS, masking is implemented using a mask-image property to provide an image to be used as the mask. When it’s 100% black the Image will be visible. When it’s 100% transparent, it will hide it, and when it’s anything in-between, it will partially mask the Image. In this article, we will explain how to use the mask-image property in CSS and also show you three ways  to use an image as a mask layer which are:

    • Masking with Image
    • Masking using Gradient
    • Masking with SVG

    Before that, there is some browser compatibility with CSS. Some browser doesn’t fully support the standard CSS masking property. You will have to prefix -webkit- to the specific property for it to be browser compatible. You can also check Can I use CSS Masks? for the browser support for CSS masks.

    When using masking in CSS, it’s advisable to correct what will happen if masking is unavailable with feature queries to detect support for mask-mage or -webkit-mask-image. While making provision for a readable fallback adding your masked version.

    @supports(-webkit-mask-image: url(#mask)) or (mask-image: url(#mask)) {
      /* insert code for your mask-image here. */
    }

    Masking Using Gradient

    Masking an image with a gradient can give a beautiful and nice-appealing look to your image. A linear gradient can mask an image area from transparent to black. For example, in the image below, the first image is our default image without a mask. While the second image has a linear gradient applied to the mask-image value:

    Read More:  7 Concepts: Why Your SVG Is the Way It Is

    This the CSS mask-image rule used for the second image in the diagram below here:

    .firstMask {
        -webkit-mask-image: linear-gradient(to bottom, transparent 10%, black);
       mask-image: linear-gradient(to bottom, transparent 10%, black);
    }
    Masking Image in CSS with Gradient
    Masking Image in CSS with Gradient

    You can also be stylistic and creative with the masking by using any gradient type. The third image in the diagram above uses a radial gradient in creating a circular mask.

    .secondMask {
        -webkit-mask-image: radial-gradient(
          circle at 50% 50%,
          black 50%,
          rgba(0, 0, 0, 0.6) 20%
        );
        mask-image: radial-gradient(
          circle at 50% 50%,
          black 50%,
          rgba(0, 0, 0, 0.6) 20%
        );
    }

    Masking with Image

    To mask an image, a fully transparent area will make the image invisible while the part with a little transparency will allow the original to be visible.

    The first image is the original image in the below example, while the second image is the image mask itself. The third image applies to the mask below.

    Masking in CSS with image
    Masking in CSS with image

    Below is the CSS style applied to the mask:

     #masked {
            width: 300px;
            height: 300px;
            -webkit-mask-box-image: url("Img/mask.png");
            mask-image: url("Img/mask.png");
          }

    Here we specified the mask-image url() which works similarly to the way the background-image property works.

    Masking with SVG

    If you love SVG as I do. Instead of using an image as the mask, you can define image masks with the SVG mask element.

    To achieve this, we will define the image as part of an SVG element itself:

    <svg
        width="300px"
        height="450px"
        viewBox="0 0 400 700"
        class="mask-svg"
        style="vertical-align: top;"
    >
       <defs>
            <mask id="svg-mask">
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="50.3643417"
                cy="250.414611"
                r="81.4648437"
              ></circle>
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="311.578293"
                cy="560.568392"
                r="50.5976606"
              ></circle>
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="220.623423"
                cy="350.467234"
                r="80.5878906"
              ></circle>
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="55.5"
                cy="60.5"
                r="63.5"
              ></circle>
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="253.61"
                cy="130.56"
                r="50.42"
              ></circle>
              <circle
                id="Oval"
                fill="#FFFFFF"
                cx="60.14"
                cy="250.41"
                r="85.46"
              ></circle>
            </mask>
          </defs>
          <image
            xlink:href="Img/bird.jpg"
            width="500"
            height="700"
            mask="url(#svg-mask)"
          ></image>
    </svg>
    
    Masking image in CSS with SVG
    Masking image in CSS with SVG

    Conclusion

    I hope you really enjoy working through this article. We have learned how to use mask in CSS to hides part of the element it is applied to. We covered how masking works with Image, Gradient, and SVG.  Also kindly check this reference below to learn more in-depth on masking.

    Read More:  Setting CSS Styles with JavaScript

    https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Masking
    https://developer.mozilla.org/en-US/docs/Web/CSS/mask

    If you have any questions, kindly engage me in the comment below.

    Share. Facebook Twitter Pinterest LinkedIn Tumblr Email
    adeneye

      Related Posts

      Style like a pro with CSS variables

      May 12, 2023

      CSS Flexbox

      May 1, 2023

      CSS Grid

      April 21, 2023
      Leave A Reply Cancel Reply

      You must be logged in to post a comment.

      Stay In Touch
      • Facebook
      • Twitter
      • Pinterest
      • Instagram
      • YouTube
      • Vimeo
      Don't Miss
      JavaScript November 16, 2020

      Getting started with Next.js

      Next.js is a React framework that allows you to build both client and server-side apps. It ships with handy features such as routing, static exporting, server rendering, internationalization.

      Build Real-world React Native App #1: Splash screen and App Icon

      November 9, 2020

      Enhancing Code Quality: Best Practices for Software Development

      November 29, 2024

      Python map() Function Explained & Visualized

      October 7, 2019

      Categories

      • AI & Automation
      • Angular
      • ASP.NET
      • AWS
      • B2B Leads
      • Beginners
      • Blogs
      • Business Growth
      • Case Studies
      • Comics
      • Consultation
      • Content & Leadership
      • CSS
      • Development
      • Django
      • E-commerce & Retail
      • Entrepreneurs
      • Entrepreneurship
      • Events
      • Express.js
      • Facebook Ads
      • Finance & Fintech
      • Flask
      • Flutter
      • Franchising
      • Funnel Strategy
      • Git
      • GraphQL
      • Home Services Marketing
      • Influencer & Community
      • Interview
      • Java
      • Java Spring
      • JavaScript
      • Job
      • Laravel
      • Lead Generation
      • Legal & Compliance
      • LinkedIn
      • Machine Learning
      • Marketing Trends
      • Medical Marketing
      • MSP Lead Generation
      • MSP Marketing
      • NestJS
      • Next.js
      • Node.js
      • Node.js Lessons
      • Paid Advertising
      • PHP
      • Podcasts
      • POS Tutorial
      • Programming
      • Programming
      • Python
      • React
      • React Lessons
      • React Native
      • React Native Lessons
      • Recruitment
      • Remote Job
      • SaaS & Tech
      • SEO & Analytics
      • Soshace
      • Startups
      • Swarm Intelligence
      • Tips
      • Trends
      • Vue
      • Wiki
      • WordPress
      Top Posts

      WordPress for Non-Programmers: Introduction to the Web Development World

      Beginners August 7, 2019

      Analyzing Emerging Trends in Health and Medical Marketing

      Medical Marketing August 27, 2025

      12. Уроки Node.js . Документация Http Модуля.

      Programming September 21, 2016

      Mastering Common Interview Questions: Strategic Responses Guide

      Interview November 29, 2024

      Subscribe to Updates

      Get The Latest News, Updates, And Amazing Offers

      About Us
      About Us

      Soshace Digital delivers comprehensive web design and development solutions tailored to your business objectives. Your website will be meticulously designed and developed by our team of seasoned professionals, who combine creative expertise with technical excellence to transform your vision into a high-impact, user-centric digital experience that elevates your brand and drives measurable results.

      7901 4th St N, Suite 28690
      Saint Petersburg, FL 33702-4305
      Phone: 1(877)SOSHACE

      Facebook X (Twitter) Instagram Pinterest YouTube LinkedIn
      Our Picks
      Startups

      Strategies for Enhancing Customer Retention in Startups

      Events

      Soshace Becomes a Media Partner of Running Remote in Bali

      Programming

      Programming Patterns. Introduction

      Most Popular

      Mastering Project Timelines: A Step-by-Step Guide

      JavaScript

      Optimizing LinkedIn: A Strategic Lead Generation Funnel Approach

      LinkedIn

      How to send multiple forms with Ajax (FormData) in Django

      Python
      © 2025 Soshace Digital.
      • Home
      • About
      • Services
      • Contact Us
      • Privacy Policy
      • Terms & Conditions

      Type above and press Enter to search. Press Esc to cancel.