Why does XHTML Strict validator not allow <input>,<a> inside a form?
This code does not validate. This is counter-intuitive to me. Inputs belong in a from correct? Yet I get a validation error for each element with in the form - input,input,a,a - to this effect:
Seems absurd to wrap it in a fieldset and then add CSS to take out the fieldset box.
Line 37,开发者_如何学运维 Column 91: document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag
<form id="f3"method="post"action="interface_add.php">
<input onkeydown="this.value=''"class="te3"type="text"name="f3a"value="title"/>
<input onkeydown="this.value=''"class="te3"type="text"name="f3b"value="url"/>
<a id="f3c"class='but'href="javascript:void(0)"onclick="interface_add()">Add</a>
<a id="f3d"class='but'href="javascript:void(0)"onclick="interface_delete()">Delete</a>
</form>
It is highly recommended (it may even be required in strict) to use a <fieldset>
when creating a form. You should include a <legend>
as well.
But why should you really do it? Accessibility. Screen readers read this information so a user knows what information they should be providing in the grand scheme. I'm pretty sure Section 508 requires it's use as well. It's been argued that federal laws don't apply to private websites, but tell that to Target, who was sued over accessibility issues.
In reality, it's not hurting anything to include it. And you can style it as you will.
Well, might seem absurd, but that's how it is. You could always file a complaint to the W3C group. So, wrap those inputs into divs, fieldsets, paragraphs or something to make the validator happy and put this nice XHTML strict logo to your site :-)
I believe it's stating that those controls should not be directly in a form, but should be in one of those elements in the form, i.e.:
<form ...>
<p>
<input ... />
</p>
</form>
精彩评论