Loading ...
Sorry, an error occurred while loading the content.

JSLinting HTML document with HTML comment at start

Expand Messages
  • cse_html_validator
    It seems JSLint cannot check an HTML document if there is an HTML comment at the beginning of the document. Can this be fixed or is there a way around it? For
    Message 1 of 7 , Jan 16, 2012
    • 0 Attachment
      It seems JSLint cannot check an HTML document if there is an HTML comment at the beginning of the document. Can this be fixed or is there a way around it?

      For example:
      <!-- test -->
      <!DOCTYPE html>
      <html>
      <head>
      <title></title>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="generator" content="CSE HTML Validator Professional (http://www.htmlvalidator.com/)">
      </head><body></body></html>

      Generates:
      Problem: Unexpected '--'.

      Thank you.
    • Martin Cooper
      ... The DOCTYPE must be the very first thing in the document, so a comment before the DOCTYPE is not valid. -- Martin Cooper
      Message 2 of 7 , Jan 16, 2012
      • 0 Attachment
        On Mon, Jan 16, 2012 at 6:30 AM, cse_html_validator <alhome@...> wrote:
        > It seems JSLint cannot check an HTML document if there is an HTML comment at the beginning of the document. Can this be fixed or is there a way around it?
        >

        The DOCTYPE must be the very first thing in the document, so a comment
        before the DOCTYPE is not valid.

        --
        Martin Cooper


        > For example:
        > <!-- test -->
        > <!DOCTYPE html>
        > <html>
        > <head>
        >        <title></title>
        >        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        >        <meta name="generator" content="CSE HTML Validator Professional (http://www.htmlvalidator.com/)">
        > </head><body></body></html>
        >
        > Generates:
        > Problem: Unexpected '--'.
        >
        > Thank you.
        >
        >
        >
        > ------------------------------------
        >
        > Yahoo! Groups Links
        >
        >
        >
      • Rob Richardson
        A comment before the DOCTYPE sends all versions of IE into quirks mode, defeating the purpose of the doctype you ve specified. See
        Message 3 of 7 , Jan 16, 2012
        • 0 Attachment
          A comment before the DOCTYPE sends all versions of IE into quirks mode,
          defeating the purpose of the doctype you've specified. See
          http://stackoverflow.com/questions/941100/can-html-comments-appear-before-th
          e-doctype-declaration Move the DOCTYPE line above the comment and you'll be
          fine. It's unfortunate the error message doesn't include this clarity.

          Rob


          -----Original Message-----
          From: jslint_com@yahoogroups.com [mailto:jslint_com@yahoogroups.com] On
          Behalf Of cse_html_validator
          Sent: Monday, January 16, 2012 7:31 AM
          To: jslint_com@yahoogroups.com
          Subject: [jslint] JSLinting HTML document with HTML comment at start



          It seems JSLint cannot check an HTML document if there is an HTML comment at
          the beginning of the document. Can this be fixed or is there a way around
          it?

          For example:
          <!-- test -->
          <!DOCTYPE html>
          <html>
          <head>
          <title></title>
          <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta
          name="generator" content="CSE HTML Validator Professional
          (http://www.htmlvalidator.com/)"> </head><body></body></html>

          Generates:
          Problem: Unexpected '--'.

          Thank you.
        • Mark Volkmann
          ... It is valid according to the HTML spec., but IE doesn t like it. See http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html and
          Message 4 of 7 , Jan 16, 2012
          • 0 Attachment
            On Mon, Jan 16, 2012 at 9:50 AM, Martin Cooper <mfncooper@...> wrote:

            > **
            >
            >
            > On Mon, Jan 16, 2012 at 6:30 AM, cse_html_validator <alhome@...>
            > wrote:
            > > It seems JSLint cannot check an HTML document if there is an HTML
            > comment at the beginning of the document. Can this be fixed or is there a
            > way around it?
            > >
            >
            > The DOCTYPE must be the very first thing in the document, so a comment
            > before the DOCTYPE is not valid.
            >

            It is valid according to the HTML spec., but IE doesn't like it.
            See http://www.whatwg.org/specs/web-apps/current-work/multipage/syntax.html
            and
            http://stackoverflow.com/questions/941100/can-html-comments-appear-before-the-doctype-declaration

            --
            R. Mark Volkmann
            Object Computing, Inc.


            [Non-text portions of this message have been removed]
          • cse_html_validator
            ... Thanks for the information on using comments before the DOCTYPE. However, it seems there is no solution to this if one decides they want or need to use
            Message 5 of 7 , Jan 31, 2012
            • 0 Attachment
              --- In jslint_com@yahoogroups.com, "Rob Richardson" <erobrich@...> wrote:
              >
              > A comment before the DOCTYPE sends all versions of IE into quirks mode,
              > defeating the purpose of the doctype you've specified. See
              > http://stackoverflow.com/questions/941100/can-html-comments-appear-before-th
              > e-doctype-declaration Move the DOCTYPE line above the comment and you'll be
              > fine. It's unfortunate the error message doesn't include this clarity.
              >
              > Rob

              Thanks for the information on using comments before the DOCTYPE.

              However, it seems there is no solution to this if one decides they want or need to use comments before the DOCTYPE? Is there anyway to tell JSLint to accept it?

              Albert
            • cse_html_validator
              Also, what if the comment is a server macro or something that will be processed by the server so it doesn t show up to the end user? Is JSLint useless for this
              Message 6 of 7 , Jan 31, 2012
              • 0 Attachment
                Also, what if the comment is a server macro or something that will be processed by the server so it doesn't show up to the end user? Is JSLint useless for this case? I would hope not.


                >
                > Thanks for the information on using comments before the DOCTYPE.
                >
                > However, it seems there is no solution to this if one decides they want or need to use comments before the DOCTYPE? Is there anyway to tell JSLint to accept it?
                >
                > Albert
                >
              • Sean Kelly
                Personally, I prefer to fix my code to follow JSLint s recommendations. That said, I also put all my Javascript in .js files and include them using script tags
                Message 7 of 7 , Feb 1, 2012
                • 0 Attachment
                  Personally, I prefer to fix my code to follow JSLint's recommendations.
                  That said, I also put all my Javascript in .js files and include them using
                  script tags so JSLint does not check my HTML, it checks my JavaScript.

                  SeanK

                  On Tue, Jan 31, 2012 at 3:47 PM, cse_html_validator <alhome@...>wrote:

                  > **
                  >
                  >
                  >
                  > Also, what if the comment is a server macro or something that will be
                  > processed by the server so it doesn't show up to the end user? Is JSLint
                  > useless for this case? I would hope not.
                  >
                  > >
                  > > Thanks for the information on using comments before the DOCTYPE.
                  > >
                  > > However, it seems there is no solution to this if one decides they want
                  > or need to use comments before the DOCTYPE? Is there anyway to tell JSLint
                  > to accept it?
                  > >
                  > > Albert
                  > >
                  >
                  >
                  >


                  [Non-text portions of this message have been removed]
                Your message has been successfully submitted and would be delivered to recipients shortly.