I have a css file which, for organizational sake, is in another directory from the one where the images are. The thing is I always end up setting all the background-images like this: background-image: url(../img/Untitled.jpg)
.
There's anything like the HTML's <base>
tag that can be used in css so I don't need to put that "../img/
" to every single background-image
?
Another possible option would be to create your css styles using php or another server side language. You can then use a directory variable to spit out the full path for each item.
styles.php
<?php
header("Content-Type: text/css");
$imageDir='../images';
// or
// $imageDir='/newsletter/2010/jan/17/business/category/7/img';
?>
.divClass{
background : url('<?php echo $imageDir; ?>/kitten.jpg');
}