Reputation: 189
My code I am trying to include in my website is not working in chrome but it is working in firefox.
Here is the code:
background-image: data:image/svg+xml,<svg%20xmlns%3D"http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg"%20viewBox%3D"0%200%2020%2020"%20style%3D"fill%3A%23000%3B"%20height%3D""%20width%3D"">%20<path%20d%3D"M8.617%2013.227C8.09%2015.98%207.45%2018.62%205.55%2020c-.587-4.162.86-7.287%201.533-10.605-1.147-1.93.138-5.812%202.555-4.855%202.975%201.176-2.576%207.172%201.15%207.922%203.89.78%205.48-6.75%203.066-9.2C10.37-.274%203.708%203.18%204.528%208.246c.2%201.238%201.478%201.613.51%203.322-2.23-.494-2.896-2.254-2.81-4.6.138-3.84%203.45-6.527%206.77-6.9%204.202-.47%208.145%201.543%208.69%205.494.613%204.462-1.896%209.294-6.39%208.946-1.217-.095-1.727-.7-2.68-1.28z"%2F><%2Fsvg>;
if you copy and paste that into firefox, it works but it does not work in chrome.
how can i fix that?
Upvotes: 1
Views: 502
Reputation: 1930
It looks like a syntax error in your css combined with a browser incompatibility with the hash character, try
background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" style="fill:%23000;" > <path d="M8.617 13.227C8.09 15.98 7.45 18.62 5.55 20c-.587-4.162.86-7.287 1.533-10.605-1.147-1.93.138-5.812 2.555-4.855 2.975 1.176-2.576 7.172 1.15 7.922 3.89.78 5.48-6.75 3.066-9.2C10.37-.274 3.708 3.18 4.528 8.246c.2 1.238 1.478 1.613.51 3.322-2.23-.494-2.896-2.254-2.81-4.6.138-3.84 3.45-6.527 6.77-6.9 4.202-.47 8.145 1.543 8.69 5.494.613 4.462-1.896 9.294-6.39 8.946-1.217-.095-1.727-.7-2.68-1.28z"/></svg>');
The main differences are that the data url is now wrapped in the css url functional notation and that the only escaped character is the hash (#) you use to declare the color because that has a reserved purpose in a url and it will cause the browser to think that the path is complete at that point.
Upvotes: 2