problem validating

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mickey0
    New Member
    • Jan 2008
    • 142

    problem validating

    hello, validating this file on w3c I have many error:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
    <script type="text/javascript" src="java.js"></script>
    
    <script type="text/javascript">
    function myFunc () {
           for (var i=0;i<100;i++) {
                var table = document.getElementById("intro");  
                var row = document.createElement("tr");
                var cell = document.createElement("td");
                var link = document.createElement("a");    
                link.setAttribute("href", "http://www.google.com");
                var linkText = document.createTextNode(" HII ");     
                link.appendChild(linkText);
                cell.appendChild(link);
                row.appendChild(cell);
                table.appendChild(row);        
        }
    }   
    </script>
     </head>
     <body onload="myFunc()">
        <table style="width: 100%" border="5" >
           <tr><td> GETTS</td> </tr>
            <tbody id="intro"><tr><td></td></tr> </tbody>
        </table>
    </body>
    </html>
    Could anyone help me? (
    character "<" is the first character of a delimiter but occurred as data.
    end tag for "head" which is not finished.
    .....
    and others...)
    EDIT: is docType ok?
  • harshmaul
    Recognized Expert Contributor
    • Jul 2007
    • 490

    #2
    a few things missing.

    Heres the full code...

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
    <title>hello world</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
     
    <script type="text/javascript" src="java.js"></script>
     
    <script type="text/javascript">
    <!--
    function myFunc() {
           for (var i=0;i < 100;i++) {
                var table = document.getElementById("intro");  
                var row = document.createElement("tr");
                var cell = document.createElement("td");
                var link = document.createElement("a");    
                link.setAttribute("href", "http://www.google.com");
                var linkText = document.createTextNode(" HII ");     
                link.appendChild(linkText);
                cell.appendChild(link);
                row.appendChild(cell);
                table.appendChild(row);        
        }
    }
    -->
    </script>
     </head>
     <body onload="myFunc()">
        <table style="width: 100%" border="5" >
           <thead><tr><td> GETTS</td> </tr></thead>
            <tbody id="intro"><tr><td></td></tr> </tbody>
        </table>
    </body>
    </html>
    firstly you need a title in the head tag
    you need to put the tables head bit in a thead tag
    finally use html comments around you javascript.

    hope that helped

    Comment

    Working...