Valhalla Legends Forums Archive | Web Development | Do forms qualify as tabular data?

AuthorMessageTime
Arta
I wondered what other people think about this.

I've recently made the switch from HTML 4.01 to XHTML1.1. One of the biggest headaches, as is generally the case, is abandoning tables for layout.

I'm pleased with the results of my switch for the most part, except for one thing: forms. The XHTML/CSS I end up with for forms, which uses floating labels to align input/select/textarea elements, really doesn't seem like an improvement over a table. It has problems, too: if the window is too small, the label text for elements has to wrap - this doesn't happen gracefully. It breaks the layout quite a bit. Also, due to the vagueries of browsers' CSS implementation, elements sometimes don't align: checkboxes don't align with textboxes under IE.

I might just be missing some CSS trick that sorts all this out, but it seems to me that forms actually do qualify as tabular data, and  tables are just better as a mechanism for presenting forms nicely.

Comments?
August 2, 2005, 2:51 PM
R.a.B.B.i.T
You can still use tables.  The XHTML validator has no problems with my pages which use tables (note: I use transitional/loose).  You DO have to handle some of the properties through CSS though, such as height, bordercolors, etc..., which can be a pain.
August 2, 2005, 6:34 PM
Arta
I know you can use tables. My point is that I'm wondering if people think that using a table for a form is a misuse of the table element, which was designed for displaying tabular data, and not for controlling layout.
August 3, 2005, 11:53 AM
Arta
By using a label element with the width specified using css.
August 3, 2005, 5:41 PM
R.a.B.B.i.T
Fuck misuse.  If it works it works.  It's just visual, so it can't hurt :)
August 3, 2005, 8:57 PM
KoRRuPT
I wrote a form thats made of span and CSS, not sure if it'll solve your problem.

[code]
<style>
.row {
clear: both;
padding-top: 5px;
}

.label {
float: left;
width: 100px;
text-align: right;
}

.form {
float: right;
width: 235px;
text-align: left;
}
.container {
width: 400px;
}
</style>
<div class="container">
<form>
<div class="row"><span class="label">Name:</span><span class="form"><input type="text" size="25" /></span></div>
<div class="row"><span class="label">Age:</span><span class="form"><input type="text" size="25" /></span></div>
<div class="row"><span class="label">Email:</span><span class="form"><input type="text" size="25" /></span></div>
<div class="row"><span class="label">Comments:</span><span class="form"><textarea cols="25" rows="8"></textarea></span>
</form>
</div>
[/code]
August 4, 2005, 5:25 AM
Arta
That's basically what I'm doing, except I'm using a <label> element rather than a span.

Another problem: The width of my containing div is 100%. When you resize the page down, the form elements extend across the right-hand border of the div. I think putting them in a table might stop that, but I haven't tried yet.
August 4, 2005, 9:34 AM
KoRRuPT
Why not just create a div that has a fixed width and surround that around your form?
August 4, 2005, 11:41 PM
R.a.B.B.i.T
[quote author=Arta[vL] link=topic=12413.msg123035#msg123035 date=1123148060]
That's basically what I'm doing, except I'm using a <label> element rather than a span.

Another problem: The width of my containing div is 100%. When you resize the page down, the form elements extend across the right-hand border of the div. I think putting them in a table might stop that, but I haven't tried yet.
[/quote]I never thought I'd have to ask Arta this, but: Got a URL or some code?
August 5, 2005, 4:55 AM
Arta
Sure.

I tried a fixed div, doesn't work.

[code]<div style="adminformwrap">
<label class="adminform" for="Type">Protocol:</label> <select class="adminform" name="Type">

<option value="b">Battle.net</option>
<option value="d">D2GS</option>
<option value="r">Realm/MCP</option>
<option value="n">Botnet</option>
<option value="u">Battle.net/Game UDP</option>
<option value="l">BNLS</option>
</select> <br />


<div><label class="adminform" for="MessageID">Message ID:</label> <input class="adminform" type="text" name="MessageID" id="MessageID" value="" /></di>

<div><label class="adminform" for="FormalName">Formal Name:</label> <input class="adminform" type="text" name="FormalName" id="FormalName" value="" /> </div>

<div class="adminform"><input class="checkbox" type="checkbox" name="NameInvented" id="NameInvented" value="1" />  <label for="NameInvented">Check this box if this formal name has been invented</label> </div>

<div><label class="adminform" for="Sender">Sender:</label>
<select class="adminform" name="Sender">
<option value="C">Client</option>

<option value="S">Server</option>
</select> </div>

<div><label class="adminform" for="Sender">Status:</label>
<select class="adminform" name="Sender">
<option value="0.5">Public Draft</option>
<option value="1">Public</option>
<option value="2">Private</option>

<option value="3">Draft (Editors only)</option>
<option value="4">Draft (Administrators only)</option>
</select> </div>

<div><label class="adminform" for="Name">Remarks Summary:</label> <input class="adminform" type="text" name="Name" id="Name" value="" /> </div>
<div><label class="adminform" for="Description">Remarks:</label> <textarea class="adminform" name="Description" id="Description"></textarea></div>

</div>
</div>
[/code]

[code]
#contentSection label.adminform
{
float: left;
display: block;
width: 12em;
}

#contentSection div.adminformwrap
{
width: 30em;
}

#contentSection input.adminform
{
width: 20em;
}

#contentSection select.adminform
{
width: 20.5em;
}

#contentSection textarea.adminform
{
width: 20.5em;
height: 15em;
}

#contentSection div.adminform
{
padding-bottom: 5px;
margin-left: 12em;
}
[/code]
August 5, 2005, 12:32 PM
R.a.B.B.i.T
Replacing all <lable>'s with <span> made it look pretty :D
[img]http://www.liquid-server.org/images/label_arta.png[/img]

[img]http://www.liquid-server.org/images/span_arta.png[/img]

[code]<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en">
<head>
<title>span!</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div style="adminformwrap">
<span class="adminform" for="Type">Protocol:</span>
<select class="adminform" name="Type">
<option value="b">Battle.net</option>
<option value="d">D2GS</option>
<option value="r">Realm/MCP</option>
<option value="n">Botnet</option>
<option value="u">Battle.net/Game UDP</option>
<option value="l">BNLS</option>
</select>
<br />
</div>
<div>
<span class="adminform" for="MessageID">Message ID:</span>
<input class="adminform" type="text" name="MessageID" id="MessageID" value="" />
</div>

<div>
<span class="adminform" for="FormalName">Formal Name:</span>
<input class="adminform" type="text" name="FormalName" id="FormalName" value="" />
</div>

<div class="adminform">
<input class="checkbox" type="checkbox" name="NameInvented" id="NameInvented" value="1" />
<span for="NameInvented">Check this box if this formal name has been invented</span>
</div>

<div>
<span class="adminform" for="Sender">Sender:</span>
<select class="adminform" name="Sender">
<option value="C">Client</option>
<option value="S">Server</option>
</select>
</div>

<div>
<span class="adminform" for="Sender">Status:</span>
<select class="adminform" name="Sender">
<option value="0.5">Public Draft</option>
<option value="1">Public</option>
<option value="2">Private</option>
<option value="3">Draft (Editors only)</option>
<option value="4">Draft (Administrators only)</option>
</select>
</div>

<div>
<span class="adminform" for="Name">Remarks Summary:</span>
<input class="adminform" type="text" name="Name" id="Name" value="" />
</div>

<div>
<span class="adminform" for="Description">Remarks:</span>
<textarea class="adminform" name="Description" id="Description"></textarea>
</div>
</body>
</html>[/code]

I changed the CSS a tad:
[code]span.adminform
{
float: left;
display: block;
width: 12em;
}

div.adminformwrap
{
width: 30em;
}

input.adminform
{
width: 20em;
}

select.adminform
{
width: 20.5em;
}

textarea.adminform
{
width: 20.5em;
height: 15em;
}

div.adminform
{
padding-bottom: 5px;
margin-left: 12em;
}[/code]
August 5, 2005, 10:19 PM
Arta
Mine looks like the second one already :P

[img]http://www.slaptop.com/stuff/editmessage.jpg[/img]

And it does this when resized, which is annoying:

[img]http://www.slaptop.com/stuff/brokeneditmessage.jpg[/img]
August 6, 2005, 10:26 AM
St0rm.iD
You probably want to use fieldsets and legends for this. See http://www.webmasterworld.com/forum83/374.htm
August 6, 2005, 3:56 PM
Arta
hmm, would a fieldset stop the form elements from breaking the boundary of the div? I'll try it, but I'm not convinced.
August 6, 2005, 4:50 PM
R.a.B.B.i.T
This is why I suggested span -.-
I've never had any overlaps with spans, and it would be easier to fix if I had the whole part :\
August 6, 2005, 7:57 PM

Search