Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML SVG Basics SVG and CSS Responsive SVGs

Embedding SVGs, Web Optimization and Responsiveness

I was just wondering if it would actually be better practice to place your SVG in your html file via an image element and create multiple detailed and less detailed SVGs that you switch out with a media query based on the page's size. Would this be possible with Javascript?

I don't know if this would be a possibility - but I worry about performance optimization seeing 20+ lines of code just for one - typically not incredibly important - image file.

1 Answer

You can now use the symbol tag in your svg. Embed that with an image tag and use css to style the svg and media queries to change the stroke widths etc responsively.