The form tag can only contain block elements — this is XHTML Strict, so neither <span> nor <input> are valid. You can wrap it in a <div> , but that's fine.
For instance:
<form action="LoginServlet" method="post"> <div>Username: <input type="text" name="name" /></div> <div>Password: <input type="password" name="password" /></div> <div><input type="submit" value="submit" /></div> </form>
However, I would advise against using XHTML, it is a thing of the past and has some serious drawbacks (for example, IE8 does not support it at all, and, unfortunately, some people still have to use it). You must use HTML5, it also has XML serialization.
source share