Jump to content

Form element


coolpro

Recommended Posts

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

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.