Re: Should svg work in less strict html5 documents with an html mime-type?

Kevin Ar18: 

>Now, I know that HTML does not follow strict xml rules, whereas SVG does.  
>However, the html5 specs say that svg is supposed to be a valid element even 
>in html documents.  It seems a little bit of a shame to have to turn all 
>html documents into the more strict xml/xhtml conforming version just to use 
>SVG.
> 
>It's probably just something that I don't understand... but I wanted to check 
>anyways. 

If you send it as application/xhtml+xml, the browsers try to interprete it 
with an XML-parser, this does not depend on the HTML5 drafts. To get
a meaningful interpretation of a document you have to add namespaces
for XHTML and SVG. And the browsers have to be able to interprete 
XHTML and SVG. The document has to follow the XML-rules to survive the
XML-parser step. 
This applies to a HTML5 document send as XML anyway, no matter 
whether it contains SVG or not.
You get some useful result as  specified for XML/XHTML and SVG. 
This works for several years in typical state of the art browsers.
On the other hand, for the XML-variant the doctype is wrong, 
should be <!DOCTYPE html> or something longer, and there is no
need for this contruct at all if you do not want to add for example
entity definitions. Because HTML5 still has no version indication, it
is not obvious anyway, that it is HTML5 and no other XHTML variant.
Other variants typically have version indications, therefore one can
identify for them, which kind of XHTML it is, if this matters.

If you send it as text/html, the browsers try to interprete it with the 
HTML-tag-soup-parser. This had no capabilities for SVG at all in the
past. Newer versions may follow already the HTML5 draft to interprete
this - but because it is only a draft, other implementors may wait until
it becomes a more stable candidate recommendation - nothing to
worry about.

Because you use completely different parsers, it is not surprise, to get
different implementation results, especially because HTML5 is only a draft 
and there are already several recommendations for XML, XHTML and SVG.

Because the XML variant works already for years in several browsers,
the results are more predictable than the HTML5+SVG result. Well, if
some browsers have already implemented this, there is a good chance,
that this will become predictable for authors once HTML5 becomes a
recommendation ;o)


Olaf

Received on Friday, 3 September 2010 09:20:08 UTC