[Solar-talk] CSS with image urls

Rodrigo Moraes rodrigo.moraes at gmail.com
Mon Dec 25 02:13:38 PST 2006


On 12/24/06, Antti Holvikari wrote:
> You know what, you're right :-). Now that I think of it, the image
> dirs *should* always be relative to the style dirs.

Browsers follow the CSS specification for url(): the image location is
relative to the file where the rule is defined (the document for
inline rules or the stylesheet file). So it is less flexible to use it
inline: you have to use absolute uri's in url() to be sure it will
work if the file is included in a different path level.

> So the
> "../"-thingy works like a charm. Even better, use it like this:
> "../../Vendor/images/..". This way you make it vendor-aware. Any
> thoughts?

It's up to you, but I think this would still be a "hardcoded" path. I
prefer more simple paths because it is easier to pack and avoids
confusion and messing with image dependencies. Just put /styles and
/images in the same level (this images dir is meant to be a layout/css
related images dir). You can organize "themes" and keep things well
separated and easy to find/manage. This can work for vendors too:

- /Theme1 or /Vendor1
    - /styles - using url(../images/...)
    - /images
- /Theme2 or /Vendor2
    - /styles - using url(../images/...)
    - /images

It's the best for maintenance and management, in my opinion.

rodrigo


More information about the solar-talk mailing list