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