vivienrk — 2014-02-25T19:54:32-05:00 — #1
In a previous closed thread (http://www.sitepoint.com/forums/showthread.php?465362-Strict-XHTML-top-of-page-navigation), I would like to know the correct place to enter <body id="top">. The code works perfectly but validation says '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). ' I placed this part of the code before <style type="text/css">. TIA
felgall — 2014-02-25T20:03:01-05:00 — #2
It is telling you the error - you have a style tag in the body where they all must go in the head.
vivienrk — 2014-02-25T20:08:30-05:00 — #3
Thanks, I'm confused. Please look at http://members.dcsi.net.au/vivienrk/p2.html.
Where is the correct place for the code on line 105 please?
felgall — 2014-02-25T20:20:21-05:00 — #4
Your page has two body tags - one at the top of the body and one part way down on line 105.
Get rid of the second body tag and put the id either on the first body tag or on whichever other tag is at the location where you want the id.
vivienrk — 2014-02-25T20:28:55-05:00 — #5
Done that (I think) but I still get an error -
Line 23, Column 15: document type does not allow element "body" here
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).
felgall — 2014-02-25T20:45:08-05:00 — #6
Your body statement on line 72 is in the correct location.
vivienrk — 2014-02-25T20:50:43-05:00 — #7
Thank you Stephen - it validates now. Maybe I didn't refresh or something but many many thanks for persevering!!
nguyencomraovat — 2014-04-06T03:24:33-04:00 — #8
Normal, i do not get id for my body and only have one of tag body. Wish greate for you.
mittineague — 2014-04-06T03:34:48-04:00 — #9
Yes, I can't see a reason for giving it an id.
id-s are supposed to be unique so that the element can be easily distinguished from others.
As body is already unique (or at least it should be) you can simply target it by "body".
vivienrk — 2014-04-06T03:39:14-04:00 — #10
Thanks Mitt and Nguyen. So what is the code to send the viewer to the top of the page and where do I place it. Thanks.
mittineague — 2014-04-06T03:46:27-04:00 — #11
AutisticCuckoo's way would be similar to how I would do it. http://www.sitepoint.com/forums/showthread.php?465362-Strict-XHTML-top-of-page-navigation&p=3317110&viewfull=1#post3317110
The "top" element inside body (the body's first child node) might not be an H1 tag, and if it already had an id I would use that instead of "top", but that's how I'd do it.
vivienrk — 2014-04-06T04:08:01-04:00 — #12
Thanks heaps Mitt!!! That passed the validation and I feel better now that I can just write <body>.
stomme_poes — 2014-04-07T14:47:13-04:00 — #13
True, though I tend to do such now and then for Back To Top widgets, where I may not know for certain that every page begins with the same first child inside the body.. so an id on the body as a link target destination is the lazy/easy way