在使用W3C进行验证时,我遇到了以下错误.
“错误:在此上下文中,元素p不允许作为元素dl的子元素.(从此子树中抑制更多错误.)”.
有谁知道如何解决这个问题?
<dl>
<dt>Comments</dt>
<dd class="auto">
<textarea name="cus-other-info" cols="45" rows="5" id="cus-other-info-id"></textarea>
</dd>
<p class="cap">ReCAPTCHA entry is for testing whether you are a human visitor and to prevent automated spam submissions.</p>
<dd class="auto recaptcha">
<div class="recaptcha-item">
<script type="text/javascript" src="http://www.google.com/recaptcha/api/challenge?k=6LfaXscSAAAAAMcN5Mfvza9CyYfV7K5__BbQiPBN"></script>
<noscript>
<iframe src="http://www.google.com/recaptcha/api/noscript?k=6LfaXscSAAAAAMcN5Mfvza9CyYfV7K5__BbQiPBN" height="300" width="500" frameborder="0"></iframe><br/>
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge"/>
</noscript> </div>
</dd>
<p><sup class="required">*</sup> = required Fields</p>
<dd class="auto recaptcha">
<div class="submit-item">
<input type="button" class="reset-but" value="Reset" onclick="clearContForm();" />
<input type="button" class="submit-but" value="Submit" onclick="formSubmit();" />
</div>
</dd>
</dl>
解决方法:
从各自的MDN docu:
Permitted content Zero or more
<dt>
elements, each followed by one or more elements.
你的< p>标签未包含< dl>或者< dt>标签.如果您更改此设置,您的代码将会验证.
此外,我建议使用标签,以满足他们的需求.再次引用MDN:
The HTML
<dl>
Element (or HTML Description List Element) encloses a list of pairs of terms and descriptions. Common uses for this element are to implement a glossary or to display Metadata (a list of key-value pairs).
从上面的代码中,我假设您只是将其用于布局和/或样式目的.