C
clumsy_ninja
I've been trying to format my form several different ways with floats:
1. no speacial markup used = input elements don't clear in IE
2. adding a br element after each input element
3. using <li> elements to group the <label> and <input> = li elements
indent oddly in Firefox
Using br elements works, but is there was a way to do this without
using extra markup like tables and br elements? Is there a CSS-only
solution to this problem?
TIA for any help!
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
input,
label {
float: left;
display: block; /* unneeded? */
width: 4em;
}
input {
margin-bottom: 1em;
width: 10em;
}
label {
clear: left;
width: 8em;
margin-right: 1em;
text-align: right;
background-color: #FFCC33;
}
ul { list-style: none; }
</style>
</head>
<body>
<fieldset>
<legend>Contact Information</legend>
<form>
<label for="name_data1">Name</label>
<input name="name_data" id="name_data1" type="text" />
<label for="name_data2">Name</label>
<input name="name_data" id="name_data2" type="text" />
<label for="name_data3">Name</label>
<input name="name_data" id="name_data3" type="text" />
</form>
</fieldset>
<fieldset>
<legend>Contact Information (using br)</legend>
<form>
<label for="name_data6">Name</label>
<input name="name_data" id="name_data6" type="text" /><br />
<label for="name_data7">Name</label>
<input name="name_data" id="name_data7" type="text" /><br />
<label for="name_data8">Name</label>
<input name="name_data" id="name_data8" type="text" /><br />
</form>
</fieldset>
<fieldset>
<legend>Contact Information (using ul)</legend>
<form>
<ul>
<li>
<label for="name_data11">Name</label>
<input name="name_data" id="name_data11" type="text" />
</li>
<li>
<label for="name_data12">Name</label>
<input name="name_data" id="name_data12" type="text" />
</li>
<li>
<label for="name_data13">Name</label>
<input name="name_data" id="name_data13" type="text" />
</li>
</ul>
</form>
</fieldset>
</body>
</html>
1. no speacial markup used = input elements don't clear in IE
2. adding a br element after each input element
3. using <li> elements to group the <label> and <input> = li elements
indent oddly in Firefox
Using br elements works, but is there was a way to do this without
using extra markup like tables and br elements? Is there a CSS-only
solution to this problem?
TIA for any help!
<!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=utf-8" />
<title>Untitled Document</title>
<style type="text/css">
input,
label {
float: left;
display: block; /* unneeded? */
width: 4em;
}
input {
margin-bottom: 1em;
width: 10em;
}
label {
clear: left;
width: 8em;
margin-right: 1em;
text-align: right;
background-color: #FFCC33;
}
ul { list-style: none; }
</style>
</head>
<body>
<fieldset>
<legend>Contact Information</legend>
<form>
<label for="name_data1">Name</label>
<input name="name_data" id="name_data1" type="text" />
<label for="name_data2">Name</label>
<input name="name_data" id="name_data2" type="text" />
<label for="name_data3">Name</label>
<input name="name_data" id="name_data3" type="text" />
</form>
</fieldset>
<fieldset>
<legend>Contact Information (using br)</legend>
<form>
<label for="name_data6">Name</label>
<input name="name_data" id="name_data6" type="text" /><br />
<label for="name_data7">Name</label>
<input name="name_data" id="name_data7" type="text" /><br />
<label for="name_data8">Name</label>
<input name="name_data" id="name_data8" type="text" /><br />
</form>
</fieldset>
<fieldset>
<legend>Contact Information (using ul)</legend>
<form>
<ul>
<li>
<label for="name_data11">Name</label>
<input name="name_data" id="name_data11" type="text" />
</li>
<li>
<label for="name_data12">Name</label>
<input name="name_data" id="name_data12" type="text" />
</li>
<li>
<label for="name_data13">Name</label>
<input name="name_data" id="name_data13" type="text" />
</li>
</ul>
</form>
</fieldset>
</body>
</html>