...

View Full Version : Validator question



SteveH
06-07-2012, 10:42 PM
Hello

I have this in a Web page:


</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="15" marginwidth="0" marginheight="0">

<table class="center">

and an online validator is telling me:
0026:[2]^[3]^<body bgcolor="#FFFFFF" leftmargin="0" topmargin="15" marginwidth="0" marginheight="0">
----:[2]^Error: <body> tag NOT allowed in <body>...</body> element. ----:[2]^Hint: error may be result of inserting implicit <body> tag.
----:[3]^Repair: discarding unexpected <body> tag.

There is only one <body> tag, so I am not sure what the validator means!

Thanks.

felgall
06-07-2012, 10:51 PM
You'll have to provide more of the page source. What the error is saying is that something earlier in the page must be in the body and so an implicit body tag has already been inserted into the page at that point.

Also your body tag and table tag have lots of meaningless junk attributes in them - try writing them correctly as <body> and <table> and specify all the page appearance info in the CSS.

imdenisejones
06-07-2012, 10:52 PM
There might be an issue with the code listed within your head tag. If you could post the section starting from the top to where your table tag begins, I might be able to figure out what the problem is.

EpicWebDesign
06-07-2012, 10:56 PM
Get rid of all that within the <body> tag and call it from your CSS file (assuming you have one). If not create a CSS file, call it externally from within the <head> of the page, and then set your styles there. This reduces the need to replicate code or use antiquated HTML such as <font face="Arial" size="2" color="red">... blah, blah, blah.

CSS stylesheets will do all of that for you if you just specify what part of the code you are styling. For example, to get rid of all that crap in the old <body> tag, :



html, body{
margin: 0px;
padding: 0px;
background: #FFFFFF;
}

Although I'm a bit confused why anyone would specify the background color as white, when that is the default... but I digresss :)

SeattleMicah
06-07-2012, 11:03 PM
Even after a few years of html/css design I never set a default bg but I just had this suggested to me a few days ago for one of my sites!!


Although I'm a bit confused why anyone would specify the background color as white, when that is the default... but I digresss


Oh and P. S.: I suppose the background of the site should be white? Because it isn’t for me as you seem to have forgotten to specify a background color and I have a different default browser background color in my browser settings.


sorry for interrupting your thread Steve, I think they'll get you sorted out easily!

EpicWebDesign
06-07-2012, 11:38 PM
Ok, i'll concede that point, but calling it from the body tag vs. CSS is just redundant. :)

SteveH
06-07-2012, 11:59 PM
Hello

Thanks to you all for your posts. This is what I have:


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

<head>

<title>myTitle</title>
<meta name="description" content="">
<meta name="keywords" content="students, ......etc">
<meta name="copyright" content="siteName">
<meta name="author" content="siteName">
<meta name="email" content="info@siteName.com">
<meta name="Distribution" content="Global">
<meta name="Rating" content="General">
<meta name="Revisit-after" content="1 Day">


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">

<!--#include file ="myDate.asp"-->

</head>

<body bgcolor="#FFFFFF" leftmargin="0" topmargin="15" marginwidth="0" marginheight="0">

<table class="center">

<tr>

<td width="558" colspan="2" align="center" valign="top" id="gradient"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td align="center" valign="top"></td>
</tr>
</table>

I do have an external CSS (too long to post here), but sometimes I lapse into the way I was originally taught and I would almost have to start from scratch to go through everything. What I will do is eliminate the one or two errors I have found and, when it is working, I will replace the old HTML styling with CSS.

Thanks again for your help.

Steve

SeattleMicah
06-08-2012, 12:01 AM
make sure to close off your </body> and </html>



<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

SteveH
06-08-2012, 12:03 AM
Thanks -
</table>
</body>

Body is closed off at the bottom of the page.

EpicWebDesign
06-08-2012, 12:30 AM
Hello

Thanks to you all for your posts. This is what I have:



<body bgcolor="#FFFFFF" leftmargin="0" topmargin="15" marginwidth="0" marginheight="0">
....


I do have an external CSS (too long to post here), but sometimes I lapse into the way I was originally taught and I would almost have to start from scratch to go through everything. What I will do is eliminate the one or two errors I have found and, when it is working, I will replace the old HTML styling with CSS.

Thanks again for your help.

Steve
Change the code above to simply read <body> and then add the CSS I provided to you earlier to your existing CSS file. If the "html, body" styling is already specified within that file, simply amend it with the lines I provided.

Sounds like you are making progress! Post a link if you get a chance so we can see what you are working with. A live URL is always the easiest way for any of us to help identify problems.

Good luck!

SteveH
06-08-2012, 12:59 AM
Thanks again. I have inserted the CSS script into the external style sheet and modified the 'aboutus' page as suggested.

I then went to netmechanic to validate it and while the page loads a bit faster, I still get those errors:


0023:[2]^[3]^</head>
----:[2]^Error: </head> tag NOT allowed in <body>...</body> element. ----:[2]^Hint: error may be result of inserting implicit <body> tag.
----:[3]^Repair: discarding unexpected </head> tag. 0024:
0025:[4]^[5]^<body>
----:[4]^Error: <body> tag NOT allowed in <body>...</body> element. ----:[4]^Hint: error may be result of inserting implicit <body> tag.
----:[5]^Repair: discarding unexpected <body> tag.

Regarding closing the <html> tag, when I did that I get an error in the CSE Validator that I have installed. The error in the validator goes when I remove </html>, which I find a bit strange.

The link is here:

http://www.proofreading4students.com/aboutus.asp

Cheers

Steve

SeattleMicah
06-08-2012, 01:06 AM
You have a illegal div in your <head></head>



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

<title>proofreading4students - about us</title>
<meta name="description" content="Proofreading service for students and academic staff">
<meta name="keywords" content="students, academic, proof reading, copy, edit, university, college, editor, editorial, correction">
<meta name="copyright" content="proofreading4students">
<meta name="author" content="proofreading4students">
<meta name="email" content="info@proofreading4students.com">
<meta name="Distribution" content="Global">
<meta name="Rating" content="General">
<meta name="Revisit-after" content="1 Day">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style.css" rel="stylesheet" type="text/css">

<div class="show_date">Thursday 7<sup>th</sup> June</div> <-----------ERROR

</head>


<body>



<table class="center">
<tr>
<td width="558" colspan="2" align="center" valign="top" id="gradient"><table width="100%" border="0" cellspacing="0" cellpadding="0">

<tr><td align="center" valign="top"></td>

</tr>


need this close


</html>


I would rework your overall layout. Try and not layout the majority of your site in tables. If someone else doesn't I will take your code into notepad++ later and make sure all your tags are opening and closing properly.

SteveH
06-08-2012, 01:42 AM
Hello SeattleMicha

Thanks again.

I have downloaded Notepad ++ and closed off the <td> tags (I now have the same amount of <td>s as I have </tds>.

I still get that original [quote[Error: </head> tag NOT allowed in <body>...</body> element.[/quote] in netmechanic and while Notepad++ tells me that I have the same number of <table> and </table> tags, netmechanic doesn't like it.

So altogether, netmechanic is showing two errors. I might try it with a different validator, but your support has been very kind.

Thanks.

HTMLValidator.c
06-08-2012, 03:33 AM
So altogether, netmechanic is showing two errors. I might try it with a different validator, but your support has been very kind.

Thanks.

You may want to try the online version of CSE HTML Validator:
http://www.OnlineWebCheck.com/

I put your HTML in it and the first error said: The "div" element cannot be used here.

It also found some other issues. I hope this helps.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum