2

.icon {
  width: 20px; height: 20px; background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
}
<div class='icon'></div>

How do I set the fill colour (using CSS) of an inline/background SVG?

Gajus
  • 69,002
  • 70
  • 275
  • 438

1 Answers1

0
.icon {
  width: 20px; height: 20px;
  background-color: red;
 -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
   mask:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
}
Fazil Abdulkhadar
  • 1,091
  • 5
  • 11