What is CDATA in HTML?

HTMLWeb DevelopmentFront End Technology

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[ ... ]]>

Here’s an example:

<p>The following is CDATA <![CDATA[ < > & ]]> with symbols that do not need escaping.
</p>

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

<script type="text/javascript">
   //<![CDATA[
   document.write(">");
   //]]>
</script>

Note: CDATA is now deprecated. Do not use.

raja
Published on 02-Jan-2018 13:51:37
Advertisements