CSS image paths

AyntRyte's picture

He has: 145 posts

Joined: Jun 2004

Just something I saw on usenet. Anyone want to comment/agree/disagree/flame/worship/etc.?

Quote:
Relative URLs are worked out differently by different browsers, which makes them awkward to use in CSS - some browsers calculate them relative to the CSS file, while others calculate relative to the HTML file; so if they are in different directories then odd things start to happen. Stick with absolute URLs in CSS

\\// Robert

The grass is always greener on the other side -- but that's because they use more manure.

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

The only browser I know that treats it relative to the HTML document is N4.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I prefer to use urls like url(/images/thisimage.gif) to avoid all concern about it.

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

Personally I always put the css file(s) in the same directory as the html files, I did wonder whether any browsers calculated it differently though, so thanks for the info Smiling

a Padded Cell our articles site!

AyntRyte's picture

He has: 145 posts

Joined: Jun 2004

I think the difficulty occurs when the style sheet is placed in a subfolder, meaning an image link such as: url(../images/bg.gif)

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

There is the base element which, I admit, I wasn't fully aware of until I ran into it in my CMS's code just now. Does it apply to stylesheets? I don't know...

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.