XHTML: <![CDATA[..script..]]>

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ralf Schneider

    XHTML: <![CDATA[..script..]]>

    Hi there,
    can anybody help me?

    It won't work! Why?
    My declaration:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>Title</title>
    <script language="JavaS cript1.1" type="text/javascript">
    <![CDATA[
    <!--
    ...script ...
    // -->
    ]]>
    </script>
    </head>
    <body>
    <noscript>
    <p>Noscript</p>
    </noscript>
    </body>
    </html>

    It works without "<![CDATA[..script..]]>"!
    Thanks for helping!
    Ralf


  • David Dorward

    #2
    Re: XHTML: &lt;![CDATA[..script..]]&gt;

    Ralf Schneider wrote:
    [color=blue]
    > It won't work! Why?
    > My declaration:
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"[/color]
    [color=blue]
    > <script language="JavaS cript1.1" type="text/javascript">[/color]

    No language attribute in Strict
    [color=blue]
    > <![CDATA[[/color]

    OK I think...
    [color=blue]
    > <!--[/color]

    Why do you have an SGML comment in there?


    --
    David Dorward http://dorward.me.uk/

    Comment

    • Martin Honnen

      #3
      Re: XHTML: &lt;![CDATA[..script..]]&gt;



      Ralf Schneider wrote:[color=blue]
      > Hi there,
      > can anybody help me?
      >
      > It won't work! Why?[/color]

      What does won't work mean? Doesn't the page validate? Or is the script
      causing script errors?
      [color=blue]
      > My declaration:
      >
      > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
      > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
      > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
      > <head>
      > <title>Title</title>
      > <script language="JavaS cript1.1" type="text/javascript">
      > <![CDATA[
      > <!--
      > ...script ...
      > // -->
      > ]]>
      > </script>[/color]

      You need
      <script type="text/javascript">
      <![CDATA[
      script code
      ]]>
      </script>
      for a XHTML page served as XML (text/xml, application/xml,
      application/xhtml+xml) to a browser.

      If you want your page to be served as text/html to a HTML browser like
      IE then you need
      <script type="text/javascript">
      //<![CDATA[
      script code
      //]]>
      </script>
      as an HTML parser doesn't know about CDATA sections

      --

      Martin Honnen


      Comment

      Working...