coolpro Posted July 19, 2008 Share Posted July 19, 2008 Why <form> element should contain block-level elements? Link to comment https://forums.phpfreaks.com/topic/115634-form-element/ 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. Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-594492 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. Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-594697 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. Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-594782 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! Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-594805 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> Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-594814 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. Link to comment https://forums.phpfreaks.com/topic/115634-form-element/#findComment-595132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.