I found this strange behavior, when using an inline svg as a background image, hex color inside fill attribute is not working:
div {
width: 40px;
height: 40px;
border: 1px dashed #000;
background-repeat: no-repeat;
background-size: contain;
background-position: center;
}
.first {
background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'><polygon fill='#F00' points='0 0, 0 100, 50 66.7, 100 100, 100 0'></polygon></svg>");
}
.last {
background-image: url("data:image/svg+xml;utf8,<svg viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'><polygon fill='red' points='0 0, 0 100, 50 66.7, 100 100, 100 0'></polygon></svg>");
}
not working (fill="#F00"):
<div class="first"></div>
working (fill="red"):
<div class="last"></div>
As per SVG specs (https://www.w3.org/TR/SVGColor12/#Color_syntax) 3 digits hex colors are supposed to work.
Any idea what is going wrong ?
PS: I noticed rgb() syntax works fine, if you are stuck with the same issue