views:

39

answers:

2

Hi Guys, web newbie here,

I have a css file on my site that references an image (pic.png) like so:

content { border: 1px solid #000000; background: #ffffff url(images/pic.png) 50% 50% repeat-x; color: #000000; }

When I use firebug I see that it tries to get:

GET /path/to/css/%22images/pic.png%22

For some reason it wraps it with url encoded quotation marks (%22), and then I get a 404 not found error.

Any ideas?

A: 

I think firefox tries to fix your code by adding quotations around the path, which you are supposed to do. Apprarently it messes up some way..

What happens if you add quotation marks manually?

Litso
also a tip because you say you're a noob: you can abbreviate colors that have three pairs of numbers by just stating the three numbers (#000000 becomes #000, #ff0033 becomes #f03)
Litso
Thanks, I tried but it doesn't work
apple_pie
could you link to your page, or an example that has the same error? Maybe there's something else causing the problem..
Litso
A: 

According to the Specification, background image should be: (as corrected by Gumbo)

"The format of a URI value is 'url(' followed by optional white space followed by an optional single quote (') or double quote (") character followed by the URI itself, followed by an optional single quote (') or double quote (") character followed by optional white space followed by ')'. The two quote characters must be the same."

Although, I never use the ' and everything works fine.. Try that and see.

If it doesn't work, try to use just background-image instead of the shortcut.

:)

Kyle Sevenoaks
W3 Schools has nothing to do with W3C. Please refer to the actual specification: http://www.w3.org/TR/CSS2/. And there you can read: “The format of a URI value is '`url(`' followed by optional white space followed by an optional single quote (`'`) or double quote (`"`) character followed by the URI itself, followed by an optional single quote (`'`) or double quote (`"`) character followed by optional white space followed by '`)`'. The two quote characters must be the same.” (http://www.w3.org/TR/CSS2/syndata.html#value-def-uri)
Gumbo
Woah, damn, got the wrong page there, thanks!
Kyle Sevenoaks
I tried adding ', didn't help. I tried using the background image like so: { border: 1px solid #000000; background-image:url(images/pic.png); color: #000000; } and it didn't work
apple_pie
Do you have a live example?
Kyle Sevenoaks