1

Let's say if I link to a background img in a css file url(img/bg.png), and the css file is at http://example.com/test/style.css and the img file is at http://example.com/test/img/bg.png

However I browse the page at http://example.com/index.html and i like to the css file via <link rel='stylesheet' type='text/css' href='test/style.css' /> with the base set to <base href="http://example.com" />

Would the css file work?

Pwnna
  • 9,178
  • 21
  • 65
  • 91

2 Answers2

1

This should work

index.html includes test/style.css , which is a valid link

AND

style.css has /test/ as root so img/bg.png is also valid link

NOTE: as a general convention it's good to include ./ when referring to current directory best choice is to refer images like ./test/bg.png from your css file

Ish
  • 28,486
  • 11
  • 60
  • 77
0

See this answer: Using relative URL in CSS file, what location is it relative to?

Community
  • 1
  • 1
bosmacs
  • 7,341
  • 4
  • 31
  • 31