Reputation: 3
I get thrown out a bunch of errors on the xhtml 1.1 validator (W3C) whenever I use a element.
As soon as I change the element to a <div>
all the errors disappear.
In browsers the forms work in both states (as a <div>
or as a <form>
element, minus the fact that when I use <div>
, the submit button will not work.
Anyone have any ideas as to why the it's coming up as invalid?
<form class="form">
Name:<br/>
<input type="text" name="firstname"/><br/>
Email Address:<br/>
<input type="text" name="email"/><br/>
Comments:<br/>
<textarea name="Comments" rows="10" cols="50">Please enter your comments here.</textarea><br/><br/>
<input type="submit" value="Done"/><br/>
</form>
LINK: Screenshot of a few of the validator errors
Upvotes: 0
Views: 92
Reputation: 775
Not sure why the question, because the validator is telling you exactly what's wrong.
You need an action
attribute on your form.
Don't use <br>
to format your markup.
Surround your input labels in actual <label>
elements, and have them associated with their appropriate inputs via the for
attribute matching the input's id
. In XHTML you can't have text in the document that isn't appropriately wrapped in an element.
<form action="#insert_your_action_here">
<label for="first_name" class="block-label">
Name:
</label>
<input type="text" id="first_name" name="firstname">
</form>
Use CSS to format your labels and inputs:
.block-label {
display: block;
}
Upvotes: 1