homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / HTML
Forum Library, Charter, Moderators: incrediBILL

HTML Forum

Using the W3C Markup Validation Service
Unsure how to fix problems found

 6:03 pm on Aug 29, 2005 (gmt 0)


On my continous mission to keep my site SE friendly, I decided to run a check of my index page through the W3C Markup Validation Service and low and behold I have 2 errors! So I have attempted to isolate the problems, however I can't seem to locate what the problem is. The 2 errors I'm getting are

"DOCTYPE" declaration not allowed in instance.

document type does not allow element "HTML" here.

Now as for anyone who has used this service it also tells you which line the problem was located at. I checked out my page in dreamweaver, which identifies lines and nothing even closely matches to what their error lines say. At the very top of my page, I call my doctype like this

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

and as far as this <html> tag is concerned, I can't find it. It actually points to the begining of a php script, <?php. I just dont get it. If anyone would like for me to post the code I can.



 6:08 pm on Aug 29, 2005 (gmt 0)

You have a DOCTYPE on line 49 in addition to the one at the first line.


 6:17 pm on Aug 29, 2005 (gmt 0)

negative. Heres my code

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

[edited by: pageoneresults at 8:01 pm (utc) on Aug. 29, 2005]
[edit reason] Removed Code Dump - Please Refer to TOS [/edit]


 6:21 pm on Aug 29, 2005 (gmt 0)

DOCTYPE must be on and only the first line. Your PHP might be adding an extra one at line 49. There is an html on line 50. Just ran it through the validator myself. That is, if your site is the same one as your email domain.


 6:23 pm on Aug 29, 2005 (gmt 0)

Thanks for the fast response

DOCTYPE is indeed on the first line. Line 49 in dreamweaver is
<td colspan="2" valign="top" bgcolor="#CFE1AF">

and line 50 is


any suggestions?


 6:27 pm on Aug 29, 2005 (gmt 0)

Don't look at the code in PHP. Look at the generated HTML code. Remember the validator does not look at PHP, it looks at the resultant HTML code.


 6:33 pm on Aug 29, 2005 (gmt 0)

gah! all it took was removing one little &nbsp;

Well thank you for that great bit of help, now onto the rest of the site :)

Keep up the great work and thanks again!


 6:33 pm on Aug 29, 2005 (gmt 0)

You are most welcome. :-)


 6:39 pm on Aug 29, 2005 (gmt 0)

hmmmm.. ok almost out of the woods. When I removed the php coding, I still got the error. I then removed the &nbsp and the error disappeared. I reinserted my php, and the errors are back....

I checked the page for any additional &nbsp and not a one to be found.

It is clearly an issue with php tags.


 7:16 pm on Aug 29, 2005 (gmt 0)

It's not an issue with the php tags, per se. It's an issue with the html generated by the php script.

Here are lines 49-52:
49. <td colspan="2" valign="top" bgcolor="#CFE1AF">
50. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
51. <html>
52. <head>

The file(s) you're including via your switch statement contain doctype, html and head tags, and is dropping them into the middle of your page where they don't belong.

And they're putting this at lines 78 and 79:
78. </body>
79. </html>

so they're also adding close-body and close-html tags in the middle of your page.

You need to edit the included pages so that they only contain the actual bit of html code and content to appear at that spot in your page. They should not be complete html documents with a doctype, head tags, body tags, etc.


 7:39 pm on Aug 29, 2005 (gmt 0)

aahh i see what youre saying! Ok, I can do that. Now also, I would prefer for these pages not to be crawled. Besides noting that in my robots.txt file, is it safe to add <meta name="robots" content="noindex"> or will that keep me in the red?


 12:21 am on Aug 30, 2005 (gmt 0)

Now also, I would prefer for these pages not to be crawled.

Is it the inserted section of the page that you don't want indexed, or the entire resulting page? If the former, rather than doing an include, you could insert the content as a separate page within a borderless iframe - the separate page including a noindex meta tag or excluded by robots.txt.


 12:43 am on Aug 30, 2005 (gmt 0)

Yea I decided to exclude in robots first, then keep an eye to see what spiders are following directions. I have seen other posts on WW talking about how some bots actually follow instruction and some dont. If a certain majority of them dont follow it, then I will just add the line to each file and see what happens next lol

I appreciate all the help here, its been a real treat to learn from everyone here :)

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / HTML
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved