Pregunta

I recently changed all of my website pages to php in order to add a menu that I don't have to update on every single page. Now, however, when I try to validate my pages with the w3c validator, I receive irrelevant errors such as 'stray start body tag' and the like. To convert to php, I changed the extension from html to php and put bits of php code where I wanted the menu (inside of the php tags of course). I think that the validator should still be able to validate my html now. What is going on? Thank you!

¿Fue útil?

Solución

Those errors are right. Let's take a closer look on the first one:

Error Line 112, Column 15: Stray doctype.

<!DOCTYPE HTML>

This means that doctype was found somewhere where he shouldn't be.
In your example it's on the line 112:

function askfirstdisqus(){ 
</script>
<!DOCTYPE HTML> <-- Line 112
<html>
<head>

Just scroll down and in the source find the reported line and you'll see the problem.
You're probably using php's include to include some files and you end up with multiple meta datas.

Otros consejos

Make sure the stray tags are only opened once. You usually see this error when embedding or including pages with full markup.

Example

Standard

<!DOCTYPE HTML>
<html>
  <body>
    <head>
    </head>
  </body>
</html>

However, you have a new DOCTYPE, body, etc tags (the stray tags) within the original, like so:

<!DOCTYPE HTML>
<html>
  <body>
    <head>
    </head>
    ....
    <!DOCTYPE HTML>
    <html>
      <body class="new_DOC">
      </body>
    </html>
    ....
  </body>
</html>
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top