In this article, we'll show you how to change the color of an SVG path in CSS. This can be done by applying a pseudo-class that targets all SVG paths in your document.
In this code example, we'll use a pseudo-element to change SVG's fill color. We can even use multiple pseudo-elements to switch between different colors. This is useful if you have more than one fill color in your SVG file.

change svg color in pseudo element

p:after {
width: 48px;
height: 48px;
display: inline-block;
content: '';
-webkit-mask: url(https://gist.githubusercontent.com/m...1bb8/heart.svg) no-repeat 50% 50%;
mask: url(https://gist.githubusercontent.com/m...1bb8/heart.svg) no-repeat 50% 50%;
-webkit-mask-size: cover;
mask-size: cover;
}

.red:after {
background-color: red;
}

.green:after {
background-color: green;
}

.blue:after {
background-color: blue;
}