Menu Close

How to change the styles of an img src SVG with CSS?

To change the styles of an img src SVG with CSS, we set the mask property.

For instance, we write

<div class="logo"></div>

to add a div.

Then we write

.logo {
  background-color: red;
  -webkit-mask: url(logo.svg) no-repeat center;
  mask: url(logo.svg) no-repeat center;
}

to set the mask property to the svg URL to render the svg in the div.

Posted in CSS