I use this technique to deliver extra stylesheets to more modern browsers. Everything works great. Pretty much every graphical browser loads the linked stylesheet, and only the more modern browsers read the imported style sheets (i.e. not NN4).
When I set the content-type to text/html everything works fine. If on the other hand I set it to application/xhtml+xml, Opera 7.51 ignores the @import statements (and so only the linked stylesheets load). I haven't tried other versions of Opera yet, but everything is fine in Firefox.
I'm checking $_SERVER["HTTP_ACCEPT"] and if the browser indicates that it will accept xhtml I set the following
Can I not rely on importing stylesheets with a document set as application/xhtml+xml or am I misunderstanding something? Should I serve every page as text/html? (I hate myself for saying this - but at least it works).
Should I be using a different method of delivering stylesheets? I could use a single stylesheet and resort to css hacks but I want to avoid that.
If anyone could duplicate this I'd be grateful to hear about it - I think I'm going mad.
Also, this is my first post on Webmaster World (hello everyone) so be kind. ;)
I haven't had a chance to test this fully, but have you tried removing the CDATA comments from around the @import statements? A quick test showed me that an uncommented @import on an XHTML document served as
Which is fairly crazy, but you might have better luck (I haven't tested it in Opera). You could also use a link element as for your first stylesheet, and in that linked stylesheet you place the two @import statements to call the two advanced stylesheets.
If you use standard HTML comments only when serving XHTML as
application/xhtml+xml, then the user agent is supposed to silently remove the contents - so your stylesheets won't load. Using an uncommented style block risks displaying the contents on-screen, but only for very old browsers (read Netscape 2).