Re: Comments on XHTML Media Types Note 20080827

On Wed, 22 Oct 2008 17:31:34 +0200, Shane McCarron <shane@aptest.com>  
wrote:

>> Don't use CDATA sections (except in <script> and <style>).
> Yeah.  Actually, I think you shouldn't use them at all.  Is there a  
> specific syntax that you believe is portable to XHTML and HTML?

If you want to use "<" or "&" in a <script> or <style> element, you have  
to use

    <script>//<![CDATA
    ...
    //]]></script>

or

    <style>/*<![CDATA[*/
    ...
    /*]]>*/</style>

for it to work in both HTML and XHTML.


>> Don't use <noscript>.
> Why not?  I am not aware of a compatibility issue,

<noscript> is parsed as a CDATA element in HTML when scripting is enabled,  
and PCDATA when scripting is disabled. In XML it's always parsed as  
PCDATA. So if you have, e.g.

    <form><noscript><input name="x"  
value="y"/></noscript><button>OK</button></form>

the input will be successful in XHTML but not in HTML (when scripting is  
enabled). (This isn't limited to just forms, though.)


>> Don't use markup in <iframe>.
> Again, why not?  I am not aware of an issue between HTML and XHTML in  
> this regard.

Same as <noscript>.


>> Use createElementNS if supported and fall back to createElement.  
>> (createElement as specced doesn't match reality and there's no interop.)
> What does createElementNS do in an HTML context?

The same as it does in an XML context.


> Or, in that context, do you believe it is not supported?

IE doesn't support createElementNS, hence the advice to fall back to  
createElement.


>> When setting innerHTML, make sure the string is both well-formed and  
>> "HTML 4 compatible".
> Agreed, although if I remember correctly innerHTML is not really part of  
> a W3C spec.

http://www.w3.org/TR/html5/dom.html#innerhtml0
http://www.w3.org/TR/html5/dom.html#innerhtml1


Cheers,
-- 
Simon Pieters
Opera Software

Received on Wednesday, 22 October 2008 16:05:32 UTC