Page 1 of 1

XHTML Clarification: forms[SOLVED]

Posted: Tue Sep 13, 2005 3:52 pm
by raghavan20
I want a way to make forms xhtml compliant where tables are used.
I have a table and two fields have to be displayed.
each field is in a <td>. I dont know how to place the <form> tag to make it XHTML compliant.
any help appreciated.

The code below does not validate.

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">
<table>
<tr>
<td>
<form action="">
	<input type="text" value="" />
</td>
<td>
	<input type="text" value="" />
</form>
</td>
</tr>
</table>
</body>
</html>

Re: XHTML Clarification: forms

Posted: Tue Sep 13, 2005 4:33 pm
by Roja
raghavan20 wrote: each field is in a <td>. I dont know how to place the <form> tag to make it XHTML compliant.
any help appreciated.
The order you open tags matter - you cannot stagger tags.

You did: Form, open. Input, open, close. TD, close.

Wait.. Where is a td there? Its OUTSIDE the form. Needs to be inside.

Lets just put the form outside the whole table, and then you can get as crazy as you want with the table. :)

Code: Select all

<form action="">
<table>
<tr>
<td>
	<input type="text" value="" />
</td>
<td>
	<input type="text" value="" />
</td>
</tr>
</table>
</form>
</body>
</html>
[/quote]

Posted: Tue Sep 13, 2005 5:28 pm
by raghavan20
i know that i am not closing <form> tags in my example.
but did not know that taking <form> tags out of <table> would be xhtml compliant.

actually i had a different large case which i managed to do it.
had something similar to this

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">

<table>
<tr>
	<td>
		<form name='frm1' action="">
			<input type="text" value="" />
	</td>
	<td>
			<input type="text" value="" />
		</form>
	</td>
</tr>
<tr>
	<td>
		<form name='frm2' action="">
			<input type="text" value="" />
	</td>
	<td>
			<input type="text" value="" />
		</form>
	</td>
</tr>
</table>
</body>
</html>

but now changed to

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Chat application - Authentication</title>
<link href="chat1.css" rel="stylesheet" type="text/css" />
</head>

<body style="margin-left:10%; margin-right:10%; ">

<table>
<tr>
	<td>
		<form name='frm1' action="">
		<table>
			<tr><td>
			
				<input type="text" value="" />
			</td>
			<td>
					<input type="text" value="" />
			</td></tr>
		</table>
		</form>
	</td>
</tr>
<tr>
	<td>
		<form name='frm2' action="">
		<table>
			<tr><td>
			
				<input type="text" value="" />
			</td>
			<td>
					<input type="text" value="" />
			</td></tr>
		</table>
		</form>
	</td>
</tr>
</table>
</body>
</html>