There was only a very brief period when this was at all helpful, and it was around 1996.
There isn't a good reason to do this anymore, as the browsers which required this have by and large disappeared from the web.
In fact, doing this can actually cause unintended problems with certain older browsers' attempts to interpret the page if it uses XHTML - from developer.mozilla.org:
Mozilla 1.1+/Opera 7
Netscape 7.0x/Mozilla 1.0.x
Internet Explorer 5.5+
Can not display the document.
You should use CDATA though...
Because if you have '<', '>', '&', etc in your code, the code won't validate :)
Hell no, nobody needs this anymore and if you do, you have some more problems to care about. When you really want to support browsers that need that, you have to watch out for a lot more things. Not even talking about the lack of css!
However, the bigger problem is, that people do this wrong. Actually your example is wrong, because the line
Another Problem nobody mentioned already is this: Within HTML comments, "--" is not allowed and that means you can't use "x--" to decrement x by one.
Not having to use CDATA blocks is one of the reasons I prefer to use HTML 4.01 Strict as my docttype, but, Staicu, I thought it used the following syntax:
<script charset="utf-8"> //<![CDATA[ //]]> </script>
Maybe the two are equivalent? Anyone know if there is an advantage to one over the other?
©2020 All rights reserved.