Safari and XHTML

I just want to share a couple of issues I’ve come across with Safari and XHTML served as application/xhtml+xml. I’m slightly annoyed by the fact that Safari doesn’t send the specific MIME types it accepts in the HTTP Accept header. Why? Because it understands application/xhtml+xml, but doesn’t tell anyone. Well, not in a way that is usable.

What it does say is that it accepts “*/*”, which indicates that it will accept all media types. While that may be true, there is another browser that also claims to accept any media type, even though it doesn’t. Yes, Internet Explorer, I’m talking about you. This is a bit unfortunate.

Because of this, it’s impossible to use the content of the HTTP Accept header to decide whether to serve XHTML as application/xhtml+xml or as text/html to Safari. Instead, you need to do specific browser sniffing, something I would rather avoid. Things would be much easier if Safari used the same approach as Mozilla and Opera for the Accept header, sending the accepted MIME types along with q factors.

Another potential problem is that Safari does not recognise named HTML entities in documents served as application/xhtml+xml. Any such entities are rendered literally. As far as I can tell, not recognising named entities is not a bug, since it isn’t required for XML parsers to recognise other named entities than the five predefined ones: &, <, >, " and '. Numerical entities are recognised, so you’ll need to convert any named entities to decimal or hexadecimal ones if you want them to display as intended in Safari.

Other than that, I’m not aware of any problems that would prevent you from serving XHTML as application/xhtml+xml to Safari. Has anyone else tried it and run into trouble?

Posted on October 3, 2004 in (X)HTML, Browsers

Comments

  1. I’ve tried to send some of my sites as application/xhtml+xml to Safari, but I ran into problems. Even in the latest version, my CSS is rendered differently than it would be as text/html. The sites’ navigation bars simply won’t work properly. It’s odd, but it’s just a simple matter of changing how my content negotiation works. Not a problem for me.

  2. I gave up on Safari, for now. Besides what you mention, I had problems with parsing stylesheets loaded via PI, and problems calling a sequence of stylesheets, and display errors (rules that work perfectly fine when using text/html). And small odd things with non-roman characters.

  3. October 4, 2004 by Roger Johansson (Author comment)

    Karl: Hmm. That does sound very odd.

    Philippe: Can the display errors you were getting be narrowed down to something specific?

  4. Who needs entitites these days? UTF-8!

Comments are disabled for this post (read why), but if you have spotted an error or have additional info that you think should be in this post, feel free to contact me.