0

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

3
  • 1
    I think you need an action attribute in your form Commented Apr 29, 2017 at 12:42
  • This has nothing to do with XHTML 1.1. All HTML versions have the same requirement, and the validator emits the error for all of them. Commented Apr 29, 2017 at 14:14
  • On the plus side, kudos for learning XHTML 1.1, which is the most sensible of all XHTML dialects. Commented Apr 29, 2017 at 14:34

1 Answer 1

1

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; } 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that, I literally have only been doing HTML properly for under a week, it just through me is all xD
np and good luck. A good resource you may want to check out, for learning HTML, would be MDN (google mdn html).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.