<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>SVG Background Hover as Data URL</title>
<style>
.container {
font-family: Poppins;
display: flex;
align-items: center;
justify-content: center;
gap: 60px;
height: 100vh;
}
.head {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.background-svg {
width: 200px;
height: 200px;
background-image: url(`data:image/svg+xml;utf8,<svg xmlns="https://www.w3.org/2000/svg"
viewBox="0 0 419 419" ><path d="M381.675,20.803c-20.584,0-37.33,16.747-37.33,37.331c0,
4.819, 0.951, 9.628, 2.772, 14.085l-61.297,
61.297 c-15.555-11.566-34.813-18.42-55.642-18.42c-16.635,
0-32.861, 4.426-47.175, 12.833l-38.512-44.224 c2.607-5.18, 3.973-10.901,
3.973-16.731c0-20.58-16.745-37.323-37.327-37.323c-20.582, 0-37.327,
16.743-37.327, 37.323 c0, 20.584, 16.745, 37.331, 37.327, 37.331c3.89, 0,
7.699-0.594, 11.365-1.77l38.083, 43.729c-15.413, 17.185-23.852, 39.139-23.852,
62.276 c0, 9.273, 1.376, 18.442, 4.094, 27.305l-83.869,
59.693c-5.893-3.667-12.614-5.59-19.63-5.59C16.745,
289.949, 0, 306.692, 0, 327.273 c0, 20.584, 16.745, 37.33, 37.328,
37.33c20.582, 0,
37.327-16.746, 37.327-37.33c0-2.755-0.303-5.486-0.904-8.159l79.983-56.924 c10.309,
14.638, 24.691, 26.114, 41.197, 32.872l-8.918, 25.146c-18.973, 1.734-33.912,
17.78-33.912,
37.17 c0, 20.582, 16.745, 37.326, 37.327, 37.326c20.582, 0, 37.328-16.744,
37.328-37.326c0-10.949-4.855-21.33-13.139-28.4l9.668-27.26 c2.343, 0.178,
4.65, 0.268, 6.893, 0.268c11.969, 0, 23.61-2.249, 34.657-6.691l40.105, 48.345c-2.775,
5.309-4.229, 11.201-4.229, 17.227 c0, 20.584, 16.743, 37.331, 37.322, 37.331c20.585, 0,
37.332-16.747, 37.332-37.331c0-20.58-16.747-37.323-37.332-37.323 c-3.691, 0-7.318,
0.539-10.822, 1.606l-37.223-44.87c21.434-17.844, 33.632-43.73,
33.632-71.738c0-20.273-6.492-39.057-17.502-54.387 l61.468-61.468c4.458,
1.819, 9.269, 2.771, 14.089, 2.771c20.581, 0, 37.325-16.743, 37.325-37.323 C419,
37.55, 402.256, 20.803, 381.675, 20.803z M230.178, 158.153c27.784, 0, 50.388, 22.604,
50.388, 50.388 c0, 27.784-22.603, 50.388-50.388, 50.388c-27.785,
0-50.39-22.604-50.39-50.388C179.788,
180.757, 202.393, 158.153, 230.178, 158.153z" fill=" %23000"/></svg>`);
background-size: cover;
background-repeat: no-repeat;
}
.background-svg:hover {
background-image: url(`data:image/svg+xml;utf8,<svg xmlns="https://www.w3.org/2000/svg"
viewBox="0 0 419 419" ><path d="M381.675,20.803c-20.584,0-37.33,16.747-37.33,37.331c0,
4.819, 0.951, 9.628, 2.772, 14.085l-61.297,
61.297 c-15.555-11.566-34.813-18.42-55.642-18.42c-16.635,
0-32.861, 4.426-47.175, 12.833l-38.512-44.224 c2.607-5.18, 3.973-10.901,
3.973-16.731c0-20.58-16.745-37.323-37.327-37.323c-20.582, 0-37.327,
16.743-37.327,
37.323 c0, 20.584, 16.745, 37.331, 37.327, 37.331c3.89, 0, 7.699-0.594,
11.365-1.77l38.083,
43.729c-15.413, 17.185-23.852, 39.139-23.852, 62.276 c0, 9.273, 1.376, 18.442, 4.094,
27.305l-83.869, 59.693c-5.893-3.667-12.614-5.59-19.63-5.59C16.745, 289.949, 0, 306.692,
0, 327.273 c0, 20.584, 16.745, 37.33, 37.328, 37.33c20.582, 0, 37.327-16.746,
37.327-37.33c0-2.755-0.303-5.486-0.904-8.159l79.983-56.924 c10.309, 14.638,
24.691, 26.114, 41.197, 32.872l-8.918, 25.146c-18.973,
1.734-33.912, 17.78-33.912,
37.17 c0, 20.582, 16.745, 37.326, 37.327, 37.326c20.582, 0, 37.328-16.744,
37.328-37.326c0-10.949-4.855-21.33-13.139-28.4l9.668-27.26 c2.343,
0.178, 4.65, 0.268, 6.893, 0.268c11.969, 0, 23.61-2.249, 34.657-6.691l40.105,
48.345c-2.775, 5.309-4.229, 11.201-4.229, 17.227 c0, 20.584, 16.743, 37.331, 37.322,
37.331c20.585, 0, 37.332-16.747, 37.332-37.331c0-20.58-16.747-37.323-37.332-37.323 c-3.691,
0-7.318, 0.539-10.822, 1.606l-37.223-44.87c21.434-17.844, 33.632-43.73,
33.632-71.738c0-20.273-6.492-39.057-17.502-54.387 l61.468-61.468c4.458,
1.819, 9.269, 2.771, 14.089, 2.771 c20.581, 0, 37.325-16.743, 37.325-37.323 C419,
37.55, 402.256, 20.803, 381.675, 20.803z M230.178, 158.153c27.784, 0, 50.388, 22.604,
50.388, 50.388 c0, 27.784-22.603, 50.388-50.388, 50.388c-27.785,
0-50.39-22.604-50.39-50.388C179.788, 180.757, 202.393, 158.153,
230.178, 158.153z" fill=" %23ff0000"/></svg>`);
}
</style>
</head>
<body>
<div class="container">
<div class="head">
<h1>SVG Background Image</h1>
<div class="background-svg"></div>
</div>
</div>
</body>
</html>