Forum Moderators: open

Message Too Old, No Replies

W3C Validation Problem

Has trouble with H2?

         

wfernley

6:53 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I get this error when I validate a page:

document type does not allow element "H2" here; missing one of "APPLET", "OBJECT", "MAP", "IFRAME", "BUTTON" start-tag.

I just have a basic H2 tag:
<h2>Section Title</h2>

Am I missing something?

Thanks in advance for your help! :)

Wes

pageoneresults

6:56 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



That is typically an error caused by an improperly nested element. What is above the <h2>? Do you have a block level element wrapped inside an inline element somewhere?

wfernley

7:00 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Here is the complete code:

<html>
<head>
<title>Title</title>
<link href="css.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="content_box">
<span class="right_bar">
<h2>Section Title</h2>
Content Content Content Content Content Content Content Content Content Content Content Content Content .<br />
<br />
</span>
content
</div>
</body>
</html>

pageoneresults

7:06 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<span class="right_bar"> 
<h2>Section Title</h2>
Content Content Content Content Content Content Content Content Content Content Content Content Content .<br />
<br />
</span>

The <span> is an inline element. You cannot wrap a block level element, the <h2> inside the <span> element. Maybe change that to a <div>? Give the content a proper wrapper such as <p> or other structural element.

<div class="right_bar"> 
<h2>Section Title</h2>
<p>Content Content Content Content Content Content Content Content Content Content Content Content Content.</p>
</div>

wfernley

7:09 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well the problem is that the span is only 250px wide and located inside a div. Basically looking like this:

¦ ¦Section Title ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦
¦ ¦ ¦

Is it possible to use a div but only have it use up 250px on the right side of the page?

Thanks again for all your help!

Wes

pageoneresults

7:16 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is it possible to use a div but only have it use up 250px on the right side of the page?

I'm going to let someone with a little more experience answer that one.

Yes, you can position the div to the right and use up 250px of horizontal space. You can either position it absolutely or relatively. You can also do some things with floats but your surrounding structure will determine how you proceed.

wfernley

7:35 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So could I change it from a span to div and then tell it to float right with a width of 250px and a height of 100%?

wfernley

7:58 pm on Mar 6, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



By just replacing the span with a div, it removed the error and displays correctly. I didn't think the issue would be that easy to solve ;)

Thanks again for your help!

Wes

g1smd

11:21 am on Mar 9, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You do not need any <br> tags to create extra spacing on screen. Use CSS to set the width of the bottom margin of the element instead.

Make your pages out of headings, paragraphs, lists, tables and forms and you will not go far wrong.