htmlformsvalidationxhtml-transitional

Errors found, tag div or p, Valid XHTML


I am trying to validate my document as XHTML 1.0 Transitional (W3C). I have the following error: document type does not allow element "div" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag which corresponds to this code:

<div style="clear: both;"></div>

also error: document type does not allow element "p" here; missing one of "object", "applet", "map", "iframe", "button", "ins", "del" start-tag

<p><span class="form-span">Do <input type="checkbox" name="own" value="yes" /> rent <input type="checkbox" name="rent" value="yes" /> other <input type="checkbox" name="rentother" value="Other" /></span></p>

code fragment:

!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional
...
<body>
<form id="form1" ...>
...
<div style="clear: both;"></div>
<p><span class="form-span">Do <input type="checkbox" name="own" value="yes" /> rent <input type="checkbox" name="rent" value="yes" /> other <input type="checkbox" name="rentother" value="Other" /></span></p>
<div style="clear: both;"></div>

<span style="width:100%;">
...
<input id="i1oc_yes" type="radio" name="i1oc" value="yes" />
<input id="i1oc_no" type="radio" name="i1oc" value="no" />
...
<div style="clear: both;"></div>
...
</span>

Please let me know what is the problem. Thanks!


Solution

  • Generally, Your problem consists of the following as stated by validator

    One possible cause for this message is that you have attempted to put a block-level element (such as <p> or <table>) inside an inline element (such as <a>, <span>, or <font>).

    So, in Your code, I see, that <div> element is inside the <span> element which is not a valid XHTML.

    Reference:

    Block-level elements

    Inline elements

    and as stated on this page:

    Generally, inline elements may contain only data and other inline elements.