Validation Errors, Element Nesting Errors |
Validation Errors, Element Nesting Errors |
MANCOMP |
Aug 26 2011, 12:19 PM
Post
#1
|
Group: Members Posts: 2 Joined: 26-August 11 Member No.: 15,264 |
I am receiving the following errors and not sure how to resolve the problem without creating more problems. I am new to this, so any help would be greatly appreciated
<div id="container" style="width: 800px; height: 900px"> <!-- Begin Masthead --> <div id="masthead" style="background: url('images/mc_ani_v2.gif'); width: 800px; height: 85px;"> <img alt="Manitowoc Composites Leading the way in High Quality Fiberglass Production in the Manitowoc, Wisconsin Area." height="85" src="images/overlay.png" width="330" /></div> <!-- End Masthead --> <!-- Begin Navigation --> <div id="navigation"> <ul style="background: #2072A6; width: 100%; height: 30px;"> <link rel="stylesheet" type="text/css" href="menu.css" /> <script type="text/javascript" src="DropMenuX.js"></script> <body> Error 1 Cannot switch views: Validation (XHTML 1.0 Transitional): Element 'link' cannot be nested within element 'ul'. Error 2 Validation (XHTML 1.0 Transitional): Element 'body' cannot be nested within element 'ul'. |
pandy |
Aug 26 2011, 12:54 PM
Post
#2
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
You know that a HTML document has two main parts, HEAD and BODY? Some of the other elements belong in HEAD and others in BODY. Only SCRIPT can be in either.
HEAD mainly contains meta information. BODY contains what will be visible on the actual page. LINK belongs in HEAD. Since you have a number of elements that belong in BODY (DIV, IMG, UL) in the beginning of the snip you posted, the validator assumes they are in BODY and LINK is misplaced. Then you get an error for the start tag for BODY. It's the other elements (except LINK and maybe SCRIPT) that should be contained in BODY, not the other way around. See how a HTML page is structured here. http://htmlhelp.com/reference/html40/structure.html#doc What goes where: http://htmlhelp.com/reference/html40/olist.html Furthermore, UL can only contain list items. You can't put anything else directly in UL. http://htmlhelp.com/reference/html40/lists/ul.html It's all about containers and what can contain what. HTML contains everything, from start tag to closing tag. It's like those Chineese boxes, you open one and find more inside. For example, P can contain EM. HTML <p> This is some <em>emphasized text</em>. </p> but EM can't contain P. So you need to look at the whole element, from start tag to closing tag, and what other elements you have stuffed in there, that is what other elements it contains. |
MANCOMP |
Aug 26 2011, 02:13 PM
Post
#3
|
Group: Members Posts: 2 Joined: 26-August 11 Member No.: 15,264 |
You know that a HTML document has two main parts, HEAD and BODY? Some of the other elements belong in HEAD and others in BODY. Only SCRIPT can be in either. HEAD mainly contains meta information. BODY contains what will be visible on the actual page. LINK belongs in HEAD. Since you have a number of elements that belong in BODY (DIV, IMG, UL) in the beginning of the snip you posted, the validator assumes they are in BODY and LINK is misplaced. Then you get an error for the start tag for BODY. It's the other elements (except LINK and maybe SCRIPT) that should be contained in BODY, not the other way around. See how a HTML page is structured here. http://htmlhelp.com/reference/html40/structure.html#doc What goes where: http://htmlhelp.com/reference/html40/olist.html Furthermore, UL can only contain list items. You can't put anything else directly in UL. http://htmlhelp.com/reference/html40/lists/ul.html It's all about containers and what can contain what. HTML contains everything, from start tag to closing tag. It's like those Chineese boxes, you open one and find more inside. For example, P can contain EM. HTML <p> This is some <em>emphasized text</em>. <p> but EM can't contain P. So you need to look at the whole element, from start tag to closing tag, and what other elements you have stuffed in there, that is what other elements it contains. Thank you, Pandy. This will be a tremendous help and I really appreciate this website - also love your avatar |
pandy |
Aug 27 2011, 12:56 AM
Post
#4
|
🌟Computer says no🌟 Group: WDG Moderators Posts: 20,730 Joined: 9-August 06 Member No.: 6 |
Thank you.
|
Lo-Fi Version | Time is now: 17th April 2024 - 09:54 PM |