Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: open
I cannot get Opera 7.51 to @import stylesheets when the document has a content-type of application/xhtml+xml.
Here's the code that's involved (I've omitted most tags in the post to save space)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en" lang="en">
<link rel="stylesheet" type="text/css" title="Standard" href="http://XXX/themes/default/style.css" />
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
@header("Content-Type: application/xhtml+xml; charset=ISO-8859-1");
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
worked fine in Opera 7.50.
Thanks for the welcome and for a prompt response.
I've made the changes you suggested and everything is working as it should. The only bug to report is me!
It didn't even occur to me that the CDATA part could be the problem. I stripped out just about everything to get to the bottom of this (yet I trusted the CDATA) lol.
Are the good old <!-- comment --> tags best used to hide the style contents from legacy browsers?
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
, 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).