Skip to content Skip to sidebar Skip to footer

Inlining Svg Code Not Displaying Svg Icon

Intuitively I feel this is possible but after googling around I am still not getting the expected outcome of displaying the custom svg icon. Expected outcome: rendering
  • Solution 1:

    One way of doing this which prevents there being a 'extra' SVG in the DOM is to inline it. That way your styling is completely within your CSS.

    There are different converters out there, I just used the first one I came across.

    .checkbox-itemsli{
        list-style-image: url("data:image/svg+xml, %3Csvg width='20' height='20' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M7 10L9 12L13 8M19 10C19 14.9706 14.9706 19 10 19C5.02944 19 1 14.9706 1 10C1 5.02944 5.02944 1 10 1C14.9706 1 19 5.02944 19 10Z' stroke='%2396D8A0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); 
    <ulclass="checkbox-items"><li>item1</li><li>item2</li><li>item3</li></ul>

    Post a Comment for "Inlining Svg Code Not Displaying Svg Icon"