user1130217
user1130217

Reputation:

CSS background:url() on external server

I am using the following css rule:

background: url("http://example.com/background.jpg");

It is not working and I suppose it is because referring to external servers is not supported. Is this true? If so, what kind of workaround I might use?

Not sure if it's relevant, but I need this inline. Testing right now on JSFiddle.

Upvotes: 8

Views: 38148

Answers (3)

GajendraSinghParihar
GajendraSinghParihar

Reputation: 9131

There may be 2 reasons why your background is not working

  1. Your container doesn't have height, width or padding (no area to show the background)
  2. The URL you specified is broken or incorrect. There is no image at the URL you specified.

Otherwise, your background: url("http://example.com/background.jpg"); is Correct

Upvotes: 10

Colin Granger
Colin Granger

Reputation: 21

I'm not sure if this was resolved or not but I had a similar problem and I found a simple solution. First off, I used background-image instead of background. Second, I made sure to include the full url. So instead of background: url("http://example.com/background.jpg"); I would put background-image: url("http://www.example.com/background.jpg");

Upvotes: 2

Jezen Thomas
Jezen Thomas

Reputation: 13800

It does work. There must be something wrong with your URL.

http://jsfiddle.net/ebLQQ/

Upvotes: 1

Related Questions