Help - Search - Members - Calendar
Full Version: Validation Errors
HTMLHelp Forums > Web Authoring > Markup (HTML, XHTML, XML)
MANCOMP
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 biggrin.gif

<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
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.
<em><p>this is plain wrong</p></em>

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
QUOTE(pandy @ Aug 26 2011, 12:54 PM) *

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.
<em><p>this is plain wrong</p></em>

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 rolleyes.gif
pandy
Thank you. blush.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.