Skip to content Skip to sidebar Skip to footer

How To Reference Image Locations In Css Asset Hosted On A Different Domain?

I have a website at http://www.link1.com where all the php and images are, and I want to load the css from different website like http://www.link2.com (this doesn't host any of the

Solution 1:

You can host your css on another host no problem. If the paddings etc are working then the css is loaded. If images are not working, check the paths specified in your css.

Edit: You should use absolute urls in your css definitions if the images are hosted on a different domain, i.e:

background: url('http://link2.com/path/to/image.jpg');

as relative paths are relative to the css location, not the parent page (except, apparently for IE, see Rob's answer below).

Solution 2:

Most browsers resolve relative paths in CSS as being relative to the CSS file's location (the exception is IE). If you are using relative paths and your images are on the pages host, that could be the source of your issue

Post a Comment for "How To Reference Image Locations In Css Asset Hosted On A Different Domain?"