

A JavaScript workaround - SVG for Everybody - is available if support for this browser is important. There is no Internet Explorer support for using SVGs with and an external source. CSS styling is still possible, although it has some limitations - be sure to add an extra class and target this in the CSS. It also improves the readability of the markup. An alternative is to use the element of SVG to reference code from an external file, which the browser can cache.

with-icon-after class to the parent element. If you want control over the spacing between the icon and text, add the. This prevents the SVG from expanding to fill the whole page if the CSS doesn't load.

The icon can easily sit before or after the text, using simple text spacing.Īlways include width and height attributes as part of the SVG markup.

icon class uses the relative em unit and is ideal for using icons inline with text, adapting the icon size to the font size of the parent element. Using an SVG file as the src of an is covered separately. This section specifically covers using inline SVG files as icons.
