HTML & CSS
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
It is telling you the error - you have a style tag in the body where they all must go in the head.
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?
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.
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).
Your body statement on line 72 is in the correct location.
Thank you Stephen - it validates now. Maybe I didn't refresh or something but many many thanks for persevering!!
Normal, i do not get id for my body and only have one of tag body. Wish greate for you.
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".
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.
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.
Thanks heaps Mitt!!! That passed the validation and I feel better now that I can just write <body>.
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
This topic is now closed. New replies are no longer allowed.