Relative path in external CSS file - relative to what?
The w3c spec states that relative paths in the CSS file are relative to the stylesheet, not the HTML file, as you might expect. But...
Date Created: 2nd January 2007
Date Modified: 2nd January 2007
The following DIV has a class of "test_relative_path" defined in "/_styles/test_relative_path.css" - it sets a background-image, but the URL in the CSS file is a relative URL (img/wetlilac.gif). But relative to what?
[Test on the BODY] - Reqd for NN4
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam elit nisi, egestas at, vestibulum non, ultrices quis, sapien. Proin ut dolor. Aenean non diam eget felis ultricies auctor. Vestibulum a neque sed nibh imperdiet viverra. Etiam aliquet fringilla purus. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Quisque sagittis euismod turpis. Sed condimentum ante. Suspendisse diam. Maecenas tempor. Donec rutrum mi. Integer dictum velit eu lectus. Mauris id elit id ipsum convallis ullamcorper. Praesent eget diam sit amet nisi molestie semper. In hac habitasse platea dictumst. Aliquam erat volutpat.
- If you see a wet-lilac background image (wetlilac.gif), then your browser behaves according to the W3C spec and is finding the image relative to the CSS file.
- If you see a wet-green background image, then it is finding the file (also called wetlilac.gif) relative to this (current) HTML file. (Which I thought was how the Mozilla browser worked - but it seems OK?!) NN4, however, does suffer from this, but the background-image can only be set on the BODY tag it seems. Test link above.
- If you see nothing but a plain light blue background then no image is being found!?!