Learn how to set an elements background image to embedded SVG. This method has an added benefit of not incurring any HTTP requests, as the SVG is simply embedded into the CSS. They can also be resized by changing the width
and height
of the element containing background image, so it’s easy to create multiple sizes of the same icon using this approach.
If you’re looking for the ability to display icons at different sizes and want to modify the SVG interaction styles (such as on :hover
), this is could be a good option. One negative to adding the interaction styles is that it requires you to duplicate selectors and the SVG markup; the more icons you have, the larger your stylesheets will become.
Two Rules:
1. The embedded svg image, should use single quote.
2. Should encoder, can use