Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Help Validating html

Options
  • 16-02-2006 11:53am
    #1
    Registered Users Posts: 7,404 ✭✭✭


    Can somebody please help. I keep getting the following message when I try to validate my HTML, I've included my code below (modified)
    Thanks
    Error Line 15 column 5: document type does not allow element "BODY" here.

    <BODY>

    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements -- such as a "style" element in the "body" section instead of inside "head" -- or two elements that overlap (which is not allowed).

    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML's rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML's "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <link rel="stylesheet" type="text/css"
    	href="MySyle.css">
    <SCRIPT LANGUAGE="JavaScript" type="text/javascript">
    function goTo(){
             window.location="URL.html";
    }
    </script>
    <title>Title</title>  
    </head>
    <h1>Header</h1>
    <BODY>
    <div><b>TEXT</b></div>
    <ul>
    <li>TEXT
    </ul>
    
    <div><b>TEXT</b></div>
    <ul>
        <li>Bullet 1
        <li>Bullet 2
        <li>Bullet 3
        <li>Bullet 4
        <li>Bullet 5
    </ul>
    
    <div><button id="StartButton" type="button" value = "Start" onClick = "goTo()">Play</button></div>
    <div id="pic"></div>
    
    </BODY>
    </html>
    


Comments

  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    </head>
    <h1>Header</h1>
    <BODY>
    You're trying to insert a Header text element outside of the body of the document.


  • Registered Users Posts: 7,404 ✭✭✭fletch


    seamus wrote:
    You're trying to insert a Header text element outside of the body of the document.
    Sorted!! Thanks Seamus I love you...:)


  • Registered Users Posts: 7,404 ✭✭✭fletch


    Right just another quicky here...the below passes the test but my JavaScript does not work. However if I move the <h1> tag into the head section, the JavaScript works but it does not pass validation....any ideas??
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    	<head>
    	<link rel="stylesheet" type="text/css"
    	href="MySyle.css">
            <script src="URL.js" type="text/javascript">
            </script>
    <title>Title</title>
    </HEAD>
    <BODY onLoad="begin()">
    <h1>Text</h1>
    .
    .
    .
    </BODY>
    </HTML>
    


  • Registered Users Posts: 7,404 ✭✭✭fletch


    Anyone any ideas...???


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    Not really, without the source of the .js file.

    Try remove the type="text/javascript" param and insert language="Javascript"

    Shouldn't make a difference but you never know. If the begin() function isn't working correctly, it strikes me as an error in the js.


  • Advertisement
  • Registered Users Posts: 7,404 ✭✭✭fletch


    Got it sorted once I took the "onLoad="begin()" out of the body tag...and everythin works and passes! YAY :)


  • Registered Users Posts: 7,404 ✭✭✭fletch


    seamus wrote:
    Not really, without the source of the .js file.

    Try remove the type="text/javascript" param and insert language="Javascript"

    Shouldn't make a difference but you never know. If the begin() function isn't working correctly, it strikes me as an error in the js.
    Hey Seamus, does the validator actually check the .js file? It didn't throw any errors relating to it and I find it hard to believe that I didn't make any mistakes.. (there's belief in myself for ya!)


  • Registered Users Posts: 68,317 ✭✭✭✭seamus


    No, the validator doesn't care about the javascript, so long as the tags are OK. I'm sure someone out there makes a Javascript "compiler" which will parse javascript code and give you any syntax errors. Unfortunately there isn't a program in existence that can take any code and tell if it does what it's supposed to, only that it is written correctly. Kind of like taking a page of random words in english, and just ensuring that the grammar and punctuation is correct :)


  • Closed Accounts Posts: 4,655 ✭✭✭Ph3n0m


    the validator concentrates on html only and placement of various elements within the document

    It wont care if your .js file works or not, as long as its there by the path defined


  • Registered Users Posts: 7,404 ✭✭✭fletch


    seamus wrote:
    No, the validator doesn't care about the javascript, so long as the tags are OK. I'm sure someone out there makes a Javascript "compiler" which will parse javascript code and give you any syntax errors. Unfortunately there isn't a program in existence that can take any code and tell if it does what it's supposed to, only that it is written correctly. Kind of like taking a page of random words in english, and just ensuring that the grammar and punctuation is correct :)
    Thanks for all the help Seamus....everything is working as expected now and validated so happy days


  • Advertisement
Advertisement