|How Opera deals with trying to import non existent CSS files|
Some very unusual behaviour!
| 12:00 pm on May 31, 2007 (gmt 0)|
I happened upon a very interesting Opera quirk that took a while to diagnose!
Due to interesting nuances with RPM (long story), a developer decided to add an @import link to a non-existent CSS file that would be included at a later date. During testing we saw some interesting results with the page rendering, things being positioned in the wrong place etc.
So, turning on Operas very nice Developer Console, I looked to see what was happening. Opera showed the CSS files it was asked to link to and there was the link to the non-existent file. However, when I clicked on the show rules button I saw some unexpected results!
I would have expected to see nothing, but instead I saw some CSS rules. These rules were coming from the Apache custom 404 page, which has some CSS in the head!
It seems that Opera, looking for a file (with content type text/css), received a 404 page which contained some text/css content which it applied to the page!
This seems like very odd behaviour. The W3C has no specification or recommendation on what user agents should do in the case of a linked CSS file not being present. IE and Firefox/Mozilla do nothing and accept the omission, Opera seems to be far more hungry with it's search for some CSS to pull in!
Now, I know that it is bad practise to try to link/import files which don't exist - and I have flogged the developer in question ;) - but is Opera doing the right thing here? Opera is excellent for standards adherence and forces us to be very exact with our code, but surely looking at the HTTP response, seeing 404 instead of 200, should have meant that it didn't try to seek for some, any CSS!