coolpro Posted July 19, 2008 Share Posted July 19, 2008 Why <form> element should contain block-level elements? Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 20, 2008 Share Posted July 20, 2008 It doesn't have to include block level elements. The elements you put in your script are for looks. Quote Link to comment Share on other sites More sharing options...
coolpro Posted July 20, 2008 Author Share Posted July 20, 2008 HTML 4.01 and XHTML Strict requieres, that form element contains block-level elements. This would be incorrect: <form> <input></input> </form> The correct one is: <form> <div> <input></input> </div> </form> But I don't understand why. Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 20, 2008 Share Posted July 20, 2008 Post a source because I haven't ever seen this information ever. Quote Link to comment Share on other sites More sharing options...
coolpro Posted July 20, 2008 Author Share Posted July 20, 2008 http://htmlhelp.com/reference/html40/forms/form.html It is true, because when I use: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <div> <form action="index.php"> <input type="text" id="field1" name="field1" /> </form> </div> </body> </html> W3C validator show error: Line 12, Column 46: 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. and when: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <div> <form action="index.php"> <div> <input type="text" id="field1" name="field1" /> </div> </form> </div> </body> </html> then: This Page Is Valid XHTML 1.0 Strict! Quote Link to comment Share on other sites More sharing options...
BillyBoB Posted July 20, 2008 Share Posted July 20, 2008 Oh yea that... I was confused I don't exactly know why it is that way I just put my form one div under the inputs... its fits in perfectly with the rest of the code and I don't get errors... I would do: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Untitled Document</title> </head> <body> <form action="index.php"> <div> <input type="text" id="field1" name="field1" /> </div> </form> </body> </html> Quote Link to comment Share on other sites More sharing options...
TheFilmGod Posted July 21, 2008 Share Posted July 21, 2008 It is required to put a level of "required" accessibility to your website. Bunching some random <input> tags together wouldn't be semantic and accessible to screen readers. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.