Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts

    w3 validator help :(

    I have posted this in HTML and CSS forum but I realise some of this is relevant here.

    Hi, I used http://validator.w3.org/ on my new site and it came back with over 40 errors which I tried my very best to fix what I understood but some of it is beyond me.

    It still returns 26 errors, my site is www.pagefrog.net

    I realise it explains how to fix it but it's still not clear to me sorry
    all help appreciated. Thanks.

  • #2
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,350
    Thanks
    13
    Thanked 349 Times in 345 Posts
    the problem is that you validate as XHTML and display the page as HTML. (note: XHTML would quit on the first error).

    if you revalidate as HTML (4.01 Strict) you're left (besides the warnings about the self-closing tags, which are illegal in HTML 4) with deprecated elements and attributes (and one superfluous end tag).
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,729
    Thanks
    6
    Thanked 1,015 Times in 988 Posts
    These errors in the JavaScript come up because you didn’t declare your JS in the XHTML document as character data (CDATA). The XHTML parser thinks it is part of the HTML and tries to parse it but in HTML all ampersands and “less than” and “greater than” characters must be encoded with appropriate entities.

    You declare your JS as character data like this:
    Code:
    <script type="text/javascript">
    // <![CDATA[
     … JS code here …
    // ]]>
    </script>
    Do that and then validate again.

  • #4
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,350
    Thanks
    13
    Thanked 349 Times in 345 Posts
    the JavaScript text issue can be best dealt with by moving the script to an external script file. this way it is not considered by the (X)HTML parser.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #5
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,642
    Thanks
    0
    Thanked 649 Times in 639 Posts
    Quote Originally Posted by VIPStephan View Post
    You declare your JS as character data like this:
    Code:
    <script type="text/javascript">
    // <![CDATA[
     … JS code here …
    // ]]>
    </script>
    If the page is using XHTML then the // on the front of those lines shouldn't be there. If the page is using HTML then those entire lines shouldn't be there. That particular combination only works if the page is HTML being fed into the XHTML validator.

    The simplest solution is to keep all the JavaScript in separate files and don't jumble it into the HTML at all.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • #6
    New Coder
    Join Date
    Jul 2011
    Posts
    23
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you so much worked a treat. 24/26 fixed!


  •  

    Posting Permissions

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