- From: Leif Halvard Silli <xn--mlform-iua@xn--mlform-iua.no>
- Date: Fri, 5 Feb 2010 15:14:23 +0100
- To: David Dorward <david@dorward.me.uk>
- Cc: www-validator@w3.org
David Dorward, Fri, 5 Feb 2010 07:25:51 +0000: > On 5 Feb 2010, at 03:56, Leif Halvard Silli wrote: >> David Dorward, Mon, 1 Feb 2010 10:51:16 +0000: >> >>> ... or you could just use a JS comment rather than depending on hacks >>> designed to avoid having Netscape 2 and friends render JS as text >>> (which would break if the script was placed in an external file). >> >> The Netscape hack comes in handy, to save HTML4 from itself! The two >> examples below validates both as XHTML and HTML4 - and at the same time >> they eliminate the need for end tag escaping in HTML4. > > It is hideous. > > 1. From an aesthetic point of view, it is just an ugly mass of code Less ugly, to me, than end tag escaping. If you do not care about XHTML validity, you can make it shorter: <script type=""></><!-- ... Variant 1: the script = a comment for HTML4 --><script type=""></script> <script type=""></><![CDATA[ ... Variant 2: the script = CDATA for HTML4 ]]><script type=""></script> > 2. It depends on browsers implementing HTML 4.01 incorrectly in order > to work HTML4 warns against using </> - doesn't expect correct implementation. > 3. It throws warnings in the validator Of course. The congratulations message counts more, though. ;-) > 4. It stops being valid HTML 4.01 as soon as the script contains the > sequence -- > > e.g. for (var i = foo.length - 1; i >= 0; i--) { Yes, that's an issue. Could be a reason to stick to variant 2 (where HTML4 perceives the script as CDATA). -- leif halvard silli
Received on Friday, 5 February 2010 14:15:00 UTC