

The width is the width in user coordinates/px units, within the SVG code, that should be scaled to fill the width of the area into which you’re drawing your SVG (the view port in SVG lingo). Its value is a list of four numbers, separated by whitespace or commas: x, y, width, height. The viewBox is an attribute of the element. It defines the origin of the SVG coordinate system, the point where x=0 and y=0.It defines how all the lengths and coordinates used inside the SVG should be scaled to fit the total space available.It defines the aspect ratio of the image.It’s the final piece that makes vector graphics Scalable Vector Graphics. The SVG viewBox is a whole lot of magic rolled up in one little attribute. What you want is to set an aspect ratio for the image, and have the drawing scale to fit. You don’t actually want to set the exact height and width anyway, you want the SVG to scale to match the width and/or height you set in the CSS. Which, as mentioned above, will be either 150px or 100vh, depending on the browser. Of course, you’re not giving up on last year’s resolution to always use responsive design, so you set svg.banner will cancel out the dimensions and aspect ratio you set in the code, and give you the default height for inline SVG. You create a fabulous header logo in Inkscape and you copy and paste the SVG code it spits out into your WordPress header file.

This year, you are going to start using SVG in your web designs. It’s not nearly as straightforward as scaling raster graphics, but that can be good, because it opens up interesting possibilities. Amelia and I both will be speaking on SVG at the upcoming RWD Summit as well! Here, she shares an epic guide to scaling SVG, covering all the ways you might want to do that. Amelia has lots of experience with SVG, as the co-author of SVG Essentials and author of the upcoming Using SVG with CSS3 and HTML5. The following is a guest post by Amelia Bellamy-Royds.
