Jim wrote:
I tried to build a "form" layout without using table like this
<snip>
The problem is that firefox and Opera (IE worked fine) don't allow any
inline component (either a span or
a div with display set to "inline") to have a width.
If you decided to build a semantically/accessability right form: then
it is much more than just make a form w/o table helpers. The fact that
you are asking about span styling suggests that you are already on the
wrong path. The proper form hierarchy implies:
form
fieldset
label element
Below there is some code to play with.
Note 1
It is crutial to define font size for input elements for a number of
browser-specific reasons. The main one is that without font size set on
IE form elements will be excluded from the page scaling (while using
font size switch).
Note 2
There is an opinion that <brtag has no semantic behind but a
presentational effect only. That is not true of course: br has a
well-defined semantic of the logical end of the current output segment.
Originally it was br (end of line) and p (end of paragraph). Later p
was promoted into block elements, but it did not remove the semantic
from br.
Note 3
Transitional instead of Strict is used only because of <utag used to
mark access keys. You are free to replace it with styled <spanand
move onto Strict then.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html401/loose.dtd">
<html>
<head>
<title>Form layout</title>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<style type="text/css">
html {
width: 100%;
margin: 0px 0px;
padding: 0px 0px;
background-color: #F5F5F5;
}
body {
width: 90%;
margin: 0px auto;
padding: 20px 20px;
border: 1px solid #000000;
background-color: #FFFFFF;
color: #000000;
font: normal 100% Verdana, Geneva, sans-serif;
}
form {
margin: 1em auto;
padding: 0px 0px;
}
form fieldset {
border: 1px solid #000000;
margin: 1em auto;
padding: 4px 4px;
}
form fieldset legend {
margin: 0px 20px;
padding: 2px 2px;
border: 1px solid #000000;
font-weight: bolder;
}
form fieldset label {
float: left;
width: 8em;
margin: 0px 0px;
padding: 2px 2px;
background-color: #ABD7F2;
text-align: right;
white-space: nowrap;
}
form fieldset input {
float: left;
width: 8em;
margin: 0px 0px;
padding: 0px 0px;
font-size: 100%;
}
form fieldset br {
clear: both;
}
</style>
</head>
<body>
<form name="frm01" method="POST" action="">
<fieldset>
<legend>Peson al data</legend>
<label for="FName" accesskey="f">< u>F</u>irst name:</label>
<input type="text" name="FName" id="FName" size="20" maxlength="64">
<label for="LName" accesskey="l">< u>L</u>ast name:</label>
<input type="text" name="LName" id="LName" size="20" maxlength="64">
<br>
<label for="EMail" accesskey="e">< u>E</u>-Mail:</label>
<input type="text" name="EMail" id="EMail" size="20" maxlength="128" >
<label for="Phone" accesskey="p">< u>P</u>hone:</label>
<input type="text" name="Phone" id="Phone" size="10" maxlength="10">
</fieldset>
</form>
</body>
</html>