Take the 2-minute tour ×

i got this stylesheet that is inside my tags of a webpage. (not a css-file because this is the only file it will ever be used in).

background-image: url("/assets/img/report/test4.png");

My background-image url doesnt include the port number for the host when using relative url.




Does not work, and is the output of relative url:


Any idea why its not including the port number?

share|improve this question
You contradict yourself in this question. "background-image does not load when using port numbers in the url." then you say localhost:8334 works but localhost doesn't. –  Andy Feb 21 '13 at 10:19
Thanks for the input @Andy, i added a hopefully better explanation. –  Christer Feb 21 '13 at 10:24
add comment

2 Answers

If your 'assets' folder is in the root why are you adding the extra '/' ? I've never used it like this, try editing it out perhaps.

share|improve this answer
add comment

Try using a relative path rather than an absolute one. Example:


share|improve this answer
I am using a relative path, url("/assets/img/report/test4.png"); Absolute paths are including the host aswell url("localhost:8080/assets/img/report/test4.png") would be a absolute path. –  Christer Feb 21 '13 at 10:10
My suggestion was to avoid the use of absolute paths. However, your answer may be found here: stackoverflow.com/questions/8317059/relative-path-but-for-port. or here: stackoverflow.com/questions/6016120/… It seems that you cannot avoid the use of js. –  otinanai Feb 21 '13 at 10:33
add comment

Your Answer


