Loading...
Loading...
In SVG, color is set through special attributes:
fill — fill colorstroke — outline colorColor can be specified directly inside SVG:
<svg>
<circle fill="red" stroke="blue" />
</svg>
If SVG is inline (inside HTML), you can style it with CSS:
svg circle {
fill: green;
stroke: black;
}
currentColor inherits text color from parent:
<div style="color: blue;">
<svg>
<path fill="currentColor" />
</svg>
</div>
If SVG is loaded via <img>, color cannot be changed with CSS.
Solution:
<object> or <use> with <symbol>Tip:
Use currentColor for icon systems — icons will automatically inherit text color.