URL as a Sass Variable

February 20, 2013

Do you ever find yourself trying to remember the URL path of you images directory? Well with Sass you can quickly add the path to the desired location and just use the variable throughout your code. Sass to the rescue.

All you need to do is declare the variable and then use the interpolation syntax when you reference it.


$get-path-to-assets : ”http://web-design-weekly/images”;

body { background: url(#{$get-path-to-assets}/classy_fabric.png) repeat-x fixed 0 0; }

More details about the interpolation syntax