The biggest issue was that end tags inside a script element are still part of the outer document so this: <b> <script type="text/javascript"> document.write('Hello!'); // Don't forget the </b> </script> </b> Would be illegal because the <b> tag was ended twice. *ARGH*