cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

              <h1>Test Scaling Of SVG Images In Fluid Layouts</h1>

<p><em>Resize your browser so that the images scale down.</em></p>

<p>Browsers IE9+ (desktop & mobile) do not respect ratios of SVG images inside <code>img</code> tags in fluid layouts. All other browsers scale SVG images as expected with the default output of an Illustrator file. This is a series of tests of SVG images using different attributes on the SVG tag.  If you want a long-form explaination, it is best to visit <a href=http://triangle717.wordpress.com/2014/06/07/ie-inkscape-svg/>Triangle717's "Internet Explorer and Inkscape SVGs"</a>.</p>

<p>One of the resolutions is to force IE to expand <code>img</code> tags containing SVG images to the desired exact (max-)width.  This is not always desired, but does at least get IE to behave itself with ratio'd scaling.  Using `max-width: 100%;` percentages do <b>not</b> work in IE when browser is not resized (normal size); the image will fill the entire contraining box (600px in this case).</p>

<p><strong>Comment or edit the media query</strong> in the CSS to view the issue in IE.</p>

<p>Other solutions are available in <a href="https://gist.github.com/larrybotha/7881691">this gist</a>.</p>

<p><small>All SVG images are 500px x 500px and constrained by the width of their containing divs for a fluid experience.</small></p>

<h2 id=preserveaspectratio>Viewbox, width, height, preserveAspectRatio</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500" width="500px" height="500px" preserveAspectRatio="xMinYMin meet"&gt;</code></p>
<p>A solution proposed <a href="http://soqr.fr/testsvg/svg-inside-img.php">here</a></p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox-width-height.svg">


<h2 id=viewbox-width-height>Viewbox, width, height - default Illustrator output</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500" width="500px" height="500px"&gt;</code></p>
<p>The default output of Illustrator. This is desired, and is what scales as expected on all non-IE browsers.</p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox-width-height.svg">


<h2 id=width-height>Width & height only - default Inkscape output</h2>
<p><code>&lt;svg ... width="500px" height="500px"&gt;</code></p>
<p>To help with a <a href="https://github.com/twitter/twemoji/issues/27">bug report</a></p>
<div class="constrain">
  <img src="https://tombyrer.github.io/svg-placeholders/fixate-inverse-with-width-height.svg">


<h2 id=viewbox>Viewbox Only</h2>
<p><code>&lt;svg ... viewBox="0 0 500 500"&gt;</code></p>
<p>Removing width and height attributes - solution proposed on <a href="http://stackoverflow.com/questions/9777143/svg-in-img-element-proportions-not-respected-in-ie9/9792254#9792254">Stack Overflow</a></p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse-with-viewbox.svg">


<h2 id=none>None of the above attributes</h2>
<p><code>&lt;svg ... &gt;</code></p>
<p>Test how browsers behave when none of the attributes used above are applied.</p>
<div class="constrain">
  <img src="https://fixate.github.io/svg-placeholders/img/fixate-inverse.svg">
              .constrain {
  max-width: 600px;
  margin: 0 auto;
  border: 1px solid #f2f2f2;
/* Ensure an image never exceeds the width of its container */
img {
  max-width: 100%;
  height: auto;

 * Let's target IE to respect aspect ratios and sizes for img tags containing SVG files
 * [1] IE9
 * [2] IE10+
// 1
img[src*=".svg"] {
  width: 500px\9; 
// 2
@media screen and (min-width:0\0) {
  img[src*=".svg"] {
    width: 500px; 

body {
  font-family: Arial;
  color: #666;
  max-width: 600px;
  margin:0 auto;
  padding: 0 2em;

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.


Loading ..................