Forums

Html Validator and HTMLpedia forums
It is currently Tue Jan 23, 2018 6:39 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Comment before doctype causes troubles
PostPosted: Fri Apr 19, 2013 2:06 pm 
Offline

Joined: Fri Apr 19, 2013 1:58 pm
Posts: 4
I have written a document which is valid on http://validator.w3.org but HTML Validator will show 93 errors. If I'm removing the comment before the doctype all is working fine. Here is the document:

Code:
<?xml
   version='1.0' encoding='utf-8'
?>

<!--
    Copyright (C) 2013 Sworddragon
    This file is part of tvoip.

    tvoip is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
-->

<!DOCTYPE
   html PUBLIC '-//W3C//DTD XHTML 1.1//EN' 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
>
<html xmlns='http://www.w3.org/1999/xhtml'>
   <head>
      <link href='index.css' rel='stylesheet' type='text/css'/>
      <link href='main.css' rel='stylesheet' type='text/css'/>
      <script src='channels.json' type='text/javascript'></script>
      <script src='lib/fullscreen.js' type='text/javascript'></script>
      <script src='lib/gcf.js' type='text/javascript'></script>
      <script src='lib/is_fullscreen.js' type='text/javascript'></script>
      <script src='lib/is_number.js' type='text/javascript'></script>
      <script src='lib/load_cookie.js' type='text/javascript'></script>
      <script src='lib/panel.js' type='text/javascript'></script>
      <script src='lib/print.js' type='text/javascript'></script>
      <script src='lib/save_cookie.js' type='text/javascript'></script>
      <script src='lib/scale.js' type='text/javascript'></script>
      <title></title>
   </head>
   <body onload='(PANEL = new panel()).__init();'>
      <table class='panel_size_min window_max'>
         <tr>
            <td class='panel panel_size_min'>
               <div class='panel panel_scroll panel_size_min' id='panel_scroll'>
                  <div class='panel_fixed'>
                     <div class='panel_power'>
                        <input class='button_power' onfocus='this.blur();' onmousedown='PANEL.button_click(BUTTON_TOGGLE_POWER);' type='button'/><!--
                        --><object class='svg_main svg_normal svg_power' data='svg/power.svg' id='svg_power'></object>
                     </div><!--
                     --><div class='panel_misc'>
                        <input class='button_fullscreen' onfocus='this.blur();' onmousedown='PANEL.button_click(BUTTON_TOGGLE_FULLSCREEN);' type='button'/><!--
                        --><object class='svg_fullscreen svg_main svg_normal' data='svg/fullscreen.svg' id='svg_fullscreen'></object><!--
                        --><input class='button_status' onfocus='this.blur();' onmousedown='PANEL.button_click(BUTTON_TOGGLE_STATUS);' type='button'/><!--
                        --><object class='svg_main svg_normal svg_status' data='svg/status.svg' id='svg_status'></object>
                     </div>
                     <div class='panel_program'>
                        <div class='panel_sound'>
                           <div>
                              <input class='panel_input' id='display_volume' onchange='PANEL.button_click(BUTTON_CHANGE_VOLUME, {"volume": PANEL.element.display_volume.value});' type='text'/><!--
                              --><input class='button_volume_up' onfocus='this.blur();' onmousedown='PANEL.button_hold_down(BUTTON_CHANGE_VOLUME_UP, 75);' type='button' value='+'/><!--
                              --><object class='svg_big svg_main svg_volume' data='svg/volume.svg' id='svg_volume_up'></object>
                           </div>
                           <div class='panel_program_vspace'>
                              <input class='button_mute' onfocus='this.blur();' onmousedown='PANEL.button_click(BUTTON_TOGGLE_MUTE);' type='button'/><!--
                              --><object class='svg_main svg_mute svg_normal' data='svg/mute.svg' id='svg_mute'></object><!--
                              --><input class='button_volume_down' onfocus='this.blur();' onmousedown='PANEL.button_hold_down(BUTTON_CHANGE_VOLUME_DOWN, 75);' type='button' value='-'/><!--
                              --><object class='svg_big svg_main svg_volume' data='svg/volume.svg' id='svg_volume_down'></object>
                           </div>
                        </div><!--
                        --><div class='panel_channels'>
                           <div>
                              <input class='panel_input' id='display_channel' onchange='PANEL.button_click(BUTTON_SELECT_CHANNEL, {"channel": PANEL.element.display_channel.value});' type='text'/><!--
                              --><input class='button_channel' onfocus='this.blur();' onmousedown='PANEL.button_hold_down(BUTTON_SELECT_CHANNEL_UP, 3000);' type='button' value='CH+'/>
                           </div>
                           <div class='panel_program_vspace'>
                              <input class='button_channel' onfocus='this.blur();' onmousedown='PANEL.button_hold_down(BUTTON_SELECT_CHANNEL_DOWN, 3000);' type='button' value='CH-'/>
                           </div>
                        </div>
                     </div>
                  </div>
                  <div class='channel_list' id='channel_list'></div>
               </div>
            </td>
            <td class='panel_size_min window_max' id='player'>
               <table class='window_max' id='video_box'>
                  <tr>
                     <td class='player window_max'>
                        <object class='window_min' data='player.swf' id='video' type='application/x-shockwave-flash'>
                           <param name='allowscriptaccess' value='always'/>
                           <param name='wmode' value='direct'/>
                        </object>
                     </td>
                  </tr>
               </table>
            </td>
         </tr>
         <tr class='status_row' id='status_row'>
            <td class='status_area' colspan='2'>
               <textarea class='status window_max' cols='0' id='status' readonly='readonly' rows='0'></textarea>
            </td>
         </tr>
      </table>
   </body>
</html>


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Wed Aug 07, 2013 7:43 am 
Offline

Joined: Wed Aug 07, 2013 7:39 am
Posts: 1
Your code seems to be proper. I feel the HTML editor must not be supporting the DOCTYPE.


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Wed Oct 16, 2013 11:28 am 
Offline

Joined: Wed Feb 11, 2009 10:51 am
Posts: 4
I have just noticed the same.
I'm using the conditional comment trick described here (http://målform.no/blog/x-ua-optimal#dothis) to be able to deliver the X-UA-Compatible meta tag to IE browsers only (because it doesn't validate).
On validator.w3.org this works just fine, however the Firefox plugin tells me that there's "no internal or external document type declaration subset; will parse without validation", which then of course will produce further errors.

Minimal test case:
Code:
<!--[if i]><![endif]-->
<!DOCTYPE html>
<html lang="en">
<head>
   <!--[if (lt IE 10)]>
   <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE" />
   <![endif]-->

   <title>My Title</title>
   <meta charset="utf-8" />
   
</head>
<body>
   <p>My Body</p>
</body>
</html>


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Sat Oct 19, 2013 8:29 pm 
Offline
Site Admin

Joined: Sat Mar 24, 2007 10:17 am
Posts: 213
This is due to the amount of space before the doctype declaration, the HTML Validator extension checks the 100 ? first characters to find the doctype.
If it is too far, I think it take the default "HTML parsing". I do this to avoid to parse the whole file.
Most of the time, there is no doctype in the HTML and it is a performance costly operation.

This is why you see this difference in behavior. Please move the doctype above in the HTML .

Thanks,

Marc


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Tue Oct 29, 2013 5:49 am 
Offline

Joined: Fri Apr 19, 2013 1:58 pm
Posts: 4
Instead of introducing a workaround for an addon on valid HTML code it may be better to rework the parsing algorithm to do it right Razz


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Mon Dec 30, 2013 1:59 pm 
Offline

Joined: Wed Feb 11, 2009 10:51 am
Posts: 4
mgueury wrote:
This is due to the amount of space before the doctype declaration, the HTML Validator extension checks the 100 ? first characters to find the doctype.
If it is too far, I think it take the default "HTML parsing". I do this to avoid to parse the whole file.
Most of the time, there is no doctype in the HTML and it is a performance costly operation.

This is why you see this difference in behavior. Please move the doctype above in the HTML .

Thanks,

Marc

The doctype is well within 100 characters in the example I posted, so there is something else wrong here.


 
 Profile  
 
 Post subject: Re: Comment before doctype causes troubles
PostPosted: Tue Nov 17, 2015 9:58 am 
Offline

Joined: Fri Sep 30, 2011 6:15 pm
Posts: 3
A bit late, I can see that. But anyways:

DOCTYPE is not really part of the HTML.
It is information about the content of the document, intended for the browser - so the browser knows what to use the document for, and how to use (parse) it.
It does not make any sense (well - a litle, but it's still wrong) to put conditional defines and comments before the DOCTYPE deklaration - the browser does not know, what to do with it. So in the case of comments it will be discarded - which is the desired action, although it is discarded for the wrong reason: browser doesn't know what to do with it - not because it is marked as a comment. To wrongs doesn't make a right, so it is an error, not to have the <!DOCTYPE as the first thing in the sourcecode.

Therefore, the <!DOCTYPE ... DTD> MUST ALWAYS be the very first thing in your sourcefile.
If it is not, browsers will (may actually - noone really knows, and it depends on the actual browser vendor and version) display the page in what is called "Quirks-mode" - ie not necessarily according to the standard you specify in the DTD (Document Type Declaration).

(HTML5 is not part of SGML - and has no DTD for that reason - but you still need to tell the browser, what kind of document it is displaying, and how it is to be parsed - the <!DOCTYPE html> MUST be the first thing in your sourcecode.)

Consider writing a document to an audience of greeks.
The document language is russian - but you don't tell the audience this from the beginning.

So I'll say, marking a missing <!DOCTYPE at the start of the document as an error is correct.
The <!DOCTYPE must be the first thing in the sourcefile.


 
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2002, 2006 phpBB Group
[ Time : 0.041s | 14 Queries | GZIP : Off ]