SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: ie7.com

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ie7.com

    I just took a look at ie7.com which is a single page ad/link for firefox.

    I've copied the page's html below, and wonder can anyone please explain the point of the
    Code:
    /* <![CDATA[ */
    at the start of the inline css. I presume that it is a hack to hide the css from some browser but since it is such a simple page I can't see why it would be required.

    The page is so basic that I can't believe it is written by anyone at firefox, there is no doctype, no h1 etc...

    Code:
    <html>
      <head>
        <title>Get Firefox</title>
        <style type="text/css">
    /* <![CDATA[ */
    
    body {
      font-family: sans-serif;
      text-align: center;
      background: #042073;
    }
    
    img {
      border: 0;
    }
    
    p {
      font-family: helvetica, sans;
      font-size: 9pt;
      color: #fff;
    }
    
    /* ]]> */
        </style>
      </head>
      <body>
        <p>Neither this site nor Mozilla is connected with Microsoft.</p>
        <a href="http://www.mozilla.com/firefox/"><img src="firefox.jpg" width="448" height="524" alt="Get Firefox"></a>
    
      </body>
    </html>

  2. #2
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks. I realize that the css comments code 'hides' it, but although I've been hunting through 'hack' sites on the web, I can't see what it is there for. Is it totally rubbish, or is it serving some purpose that I can't fathom out?

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. So I found this at: w3schools.com

    Code:
    CDATA
    
    Everything inside a CDATA section is ignored by the parser.
    
    If your text contains a lot of "<" or "&" characters - as program code often does - the XML element can be defined as a CDATA section.
    
    A CDATA section starts with "<![CDATA[" and ends with "]]>":
    
    <script>
    <![CDATA[
    function matchwo(a,b)
    {
    if (a < b && a < 0) then
       {
       return 1
       }
    else
       {
       return 0
       }
    }
    ]]>
    </script>
    
    In the example above, everything inside the CDATA section is ignored by the parser.
    Notes on CDATA sections:
    
    A CDATA section cannot contain the string "]]>", therefore, nested CDATA sections are not allowed.
    
    Also make sure there are no spaces or line breaks inside the "]]>" string.
    Since the page doesn't have a DOCTYPE of any sort let alone XHTML it seems pointless to include the cdata tags.

  4. #4
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It is used for XHTML pages that needs to work as both text/html and as XML, and when the style element contains "&" or "<". None of these conditions are true for ie7.com so it's not needed.

    An example of when it might be needed:
    HTML Code:
    <!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">
     <head>
      <title>foo</title>
      <style type="text/css">
       /* <![CDATA[ */
       p::before { content:"<"; }
       p::after { content:">"; }
       /* ]]> */
      </style>
     </head>
     <body>
      <p>bar</p>
     </body>
    </html>
    When interpreted as XML the style element is equivalent to:
    Code:
      <style type="text/css">
       /*  */
       p::before { content:"&lt;"; }
       p::after { content:"&gt;"; }
       /*  */
      </style>
    Simon Pieters

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2005
    Location
    Osoyoos BC Canada
    Posts
    178
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you both for your help and advice. I'm glad to know that it serves no purpose in the context of that page.

    I tried to find out who 'owns' ie7.com but their whois entry is hidden. I would have asked them directly if I could.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •