# When is a CDATA section necessary within a script tag?

JavascriptWeb DevelopmentFront End Technology

To avoid parsing the symbols <> &, it is added in <script>…</script>. It is not needed in HTML. Let us see how CDATA is added in <script> tags:

<script>
//<![CDATA[
document.write(">");
//]]>
</script>

Note: CDATA is now deprecated. Do not use.

The CDATA Section interface is used within XML for including extended portions of text. This text is unescaped text, like < and & symbols. These symbols do not want to escape.

It is used like this:

<![CDATA[ ... ]]>
Published on 22-Jan-2018 08:55:10