Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 14 of 14
  1. #1
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post

    Validator question

    Hello

    I have this in a Web page:

    Code:
    </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.

  • #2
    Master Coder felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, Australia
    Posts
    6,471
    Thanks
    0
    Thanked 634 Times in 624 Posts
    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.
    Stephen
    Learn Modern JavaScript - http://javascriptexample.net/
    Helping others to solve their computer problem at http://www.felgall.com/

    Don't forget to start your JavaScript code with "use strict"; which makes it easier to find errors in your code.

  • Users who have thanked felgall for this post:

    SteveH (06-07-2012)

  • #3
    New to the CF scene
    Join Date
    Jun 2012
    Location
    Chicago, Il
    Posts
    7
    Thanks
    0
    Thanked 3 Times in 3 Posts

    Post

    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.

  • Users who have thanked imdenisejones for this post:

    SteveH (06-07-2012)

  • #4
    Regular Coder
    Join Date
    Apr 2012
    Posts
    165
    Thanks
    1
    Thanked 39 Times in 39 Posts
    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, :

    Code:
    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
    Last edited by EpicWebDesign; 06-07-2012 at 09:57 PM. Reason: typos

  • Users who have thanked EpicWebDesign for this post:

    SteveH (06-07-2012)

  • #5
    Regular Coder
    Join Date
    Dec 2011
    Posts
    201
    Thanks
    12
    Thanked 26 Times in 26 Posts
    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!
    Last edited by SeattleMicah; 06-07-2012 at 10:07 PM.

  • Users who have thanked SeattleMicah for this post:

    SteveH (06-07-2012)

  • #6
    Regular Coder
    Join Date
    Apr 2012
    Posts
    165
    Thanks
    1
    Thanked 39 Times in 39 Posts
    Ok, i'll concede that point, but calling it from the body tag vs. CSS is just redundant.

  • #7
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Hello

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

    Code:
    <!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

  • #8
    Regular Coder
    Join Date
    Dec 2011
    Posts
    201
    Thanks
    12
    Thanked 26 Times in 26 Posts
    make sure to close off your </body> and </html>


    Code:
    <!DOCTYPE html>
    <html>
    <body>
    
    <h1>My First Heading</h1>
    
    <p>My first paragraph.</p>
    
    </body>
    </html>
    Last edited by SeattleMicah; 06-07-2012 at 11:04 PM.

  • #9
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    Thanks -
    Code:
    </table>
    </body>
    Body is closed off at the bottom of the page.

  • #10
    Regular Coder
    Join Date
    Apr 2012
    Posts
    165
    Thanks
    1
    Thanked 39 Times in 39 Posts
    Quote Originally Posted by SteveH View Post
    Hello

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

    Code:
    <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!

  • #11
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    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

  • #12
    Regular Coder
    Join Date
    Dec 2011
    Posts
    201
    Thanks
    12
    Thanked 26 Times in 26 Posts
    You have a illegal div in your <head></head>
    Code:
    <!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
    Code:
    </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.

  • #13
    Regular Coder
    Join Date
    Nov 2005
    Posts
    750
    Thanks
    138
    Thanked 1 Time in 1 Post
    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.

  • #14
    New to the CF scene
    Join Date
    May 2009
    Location
    Dallas, TX
    Posts
    2
    Thanks
    0
    Thanked 1 Time in 1 Post
    Quote Originally Posted by SteveH View Post
    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.

  • Users who have thanked HTMLValidator.c for this post:

    SteveH (06-08-2012)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •