Developers › ODIN blog

How media queries allow you to optimize SVG icons for several sizes

October 12, 2009 · by Andreas Bovens

One thing that seems to come up from time to time when talking about SVG is the apparent lack of a mechanism to make certain size specific adjustments. Typical use case is icon design, where you want to make sure the outline of the icon you're creating is always 1px, regardless of the icon being 16, 32 or 64 pixels in size. While at the SVG Open conference last week, I investigated how this problem could be solved, and found out that you can do this by using media queries inside the SVG file. Different widths set on the img tag pointing to the SVG file then will trigger different max-width/min-width media queries to be triggered. I've presented my findings during the lightning talks session at SVG Open, and have turned the talk into a YouTube video, which you can watch below.

Video on YouTube

Referenced demos:

Readers' comments 2

Left under the original article, as archived.

  • ouzowtfMonday, October 12, 2009 4:59:47 PM

    :up:
  • Charles SchlossTuesday, October 13, 2009 5:39:31 AM

    :up:

About this article

Published inODIN blog
DateOctober 12, 2009
AuthorAndreas Bovens
TagsOpera, svg open, video, SVG, media queries
OriginalInternet Archive