Grow your CSS skills. Land your dream job.

Validation error when embedding Google Map

  • # August 18, 2009 at 4:52 am

    Hi,

    Trying to embed a google map into a web site and keep getting a validation error from the W3C checker

    Line 64, Column 50: document type does not allow element "body" here

    <body onload="initialize()" onunload="GUnload()"/>

    The element named above was found in a context where it is not allowed. This could mean that you have incorrectly nested elements — such as a "style" element in the "body" section instead of inside "head" — or two elements that overlap (which is not allowed).

    One common cause for this error is the use of XHTML syntax in HTML documents. Due to HTML’s rules of implicitly closed elements, this error can create cascading effects. For instance, using XHTML’s "self-closing" tags for "meta" and "link" in the "head" section of a HTML document may cause the parser to infer the end of the "head" section and the beginning of the "body" section (where "link" and "meta" are not allowed; hence the reported error).

    I think I have follwed the Google instructions and the problem is certainly with the position of the ‘onload’ statement at line 64. HTML code below

    Code:
    1. < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    3.
    4.
    5.
    6.
    7.
    8. 9.
    11.
    26.

    38.
    39.

    44.
    45.
    46.

    47.

    51.

    62.

    63.
    64.
    65.

    66.

    67.

    68.

    69.

    71.

    72.
    73.
    74.
    75.

    Probably my lack of experience – any help to resolve gratefully accpeted (web page works OK ?)

    John C

    # August 18, 2009 at 6:22 am

    well, ive not worked with google maps yet, but.. i get the impression that your body with onload should basically replace your body tag at the top of the page. You can’t have two bodys to your document, it’s a unique block.

    take the onload=” onunload…. and put them inside the body tag on line 45, then delete the second body tag, completely

    like so

    Code:
    1. < !DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    3.
    4.
    5.
    6.
    7.
    8. 9.
    11.
    26.

    38.
    39.

    44.
    45.
    46.

    47.

    51.

    62.

    63.
    64.
    65.

    66.

    67.

    68.

    69.

    71.

    72.
    73.
    74.
    75.

    # August 18, 2009 at 8:19 am

    Greg,

    Thanks for the reply – yes, conflict was in having 2 body entries – have moved the onload statement up to the top body entry and it now validates.

    Thanks for your help

    John C

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".