application/xhtml+xml and html[xmlns]
On 31 Aug 2002, Edwardson Tan announced on CSS-D that he had found an easier way to hide styles from Opera than the Owen Hack.
However, this method will not work for documents sent as application/xhtml+xml.
This method works well for hiding CSS from Opera 6.05 and lower, and it also works to hide CSS from IE6.
The method included defining styles this way:
DIV { color: blue ; background-color: red; }
html[xmlns] DIV { color: white; background-color: black; }
This was only valid for documents which have an XML Namespace (generally speaking these would be XHTML files, not just HTML files).
Mozilla (and other browsers based on it) would give you a black background with white letters. Other browsers would give you a red background with blue letters.
This has become my preferred method of hiding styles from Opera 6.05 and lower. However, I just ran into a kink.
If documents are sent with MIME type application/xhtml+xml then even Mozilla will ignore styles which use the [xmlns] method defined above. I do not know enough about the specifications, etc to know whether or not this would be considered a bug, but it is definitely the reality, at least through Mozilla 1.2b (Gecko/20021017).
‡
Comments
At last, someone found a shorter CSS hack code to hide from Opera 6. I wonder if Opera 7 will read this though...
Posted by: cheeaun | October 19, 2002 07:27 AM
Who knows, Opera7 may have _complete_ support of (the relevant bits of) CSS 1 and 2, or at least a similar level as Mozilla, making CSS browser sniffing not necessary :)
Posted by: Jor | October 19, 2002 02:45 PM