/    Sign up×
Community /Pin to ProfileBookmark

use table for forms?

Hi guys,

Seeing now that I’ve pretty much transitioned to doing complete layouts with css, I was wondering about the use of tables for displaying forms.

Are form elements and their labels considered tabular data that can be displayed using a table?

Thoughts, anyone?

Thanks!

to post a comment
CSS

8 Comments(s)

Copy linkTweet thisAlerts:
@ray326Dec 17.2004 — I think the general concensus has been that you could think of label=th and input=td so a table would have valid syntax. Lately I've been using a <div><label><input></div> sort of pattern to do it sans tables.
Copy linkTweet thisAlerts:
@NogDogDec 17.2004 — I am not claiming this is [i]the[/i] way to do it, but I was playing around with how to line up form elements without using tables and came up with this:
<i>
</i>&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd"&gt;
&lt;html lang='en'&gt;
&lt;head&gt;
&lt;META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=ISO-8859-1'&gt;
&lt;title&gt;Form&lt;/title&gt;
&lt;style type="text/css"&gt;
label {
display: block;
float: left;
clear: left;
width: 8em;
}
p.form {
margin: 2px;
padding: 2px;
}
div.form {
margin: 1em auto;
clear: both;
background-color: silver;
border: solid navy 2px;
padding: 1em;
width: 35em;
}
h1 {
text-align: center;
}
&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;A Form&lt;/h1&gt;
&lt;div class=form&gt;
&lt;form id="form" action="?" method="post"&gt;
&lt;p class=form&gt;
&lt;label for="field1"&gt;This is a test:&lt;/label&gt;
&lt;input id="field1" type="text" size=20 maxlength=40&gt;
&lt;/p&gt;
&lt;p class=form&gt;
&lt;label for="field2"&gt;Test2:&lt;/label&gt;
&lt;input id="field2" type="text" size=20 maxlength=40&gt;
&lt;/p&gt;
&lt;p class=form&gt;
&lt;label for"select"&gt;My Select List:&lt;/label&gt;
&lt;select id="select"&gt;
&lt;option&gt;one&lt;/option&gt;
&lt;option&gt;two&lt;/option&gt;
&lt;option&gt;three&lt;/option&gt;
&lt;/select&gt;
&lt;/p&gt;
&lt;p class=form&gt;
&lt;label for="area"&gt;Text Area:&lt;/label&gt;
&lt;textarea id="area" cols=40 rows=10&gt;This is a test.&lt;/textarea&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@toicontienDec 17.2004 — http://template-tk.ispi.net/dguide/index.v?fp=search_form&ac=adv_search&template=L1

http://template-tk.ispi.net/vdirectory/index.v?fp=Account_Login&ac=Register&template=L1 (click this link, then you'll have to hit Refresh to see the page)

Just a couple of real-world examples that don't use tables for form layouts. But I still think tables are OK. It's really just your preference.
Copy linkTweet thisAlerts:
@ajimenezauthorDec 17.2004 — Thanks for the prompt reply guys.

I also found this at A List A Part:

[URL=http://realworldstyle.com/forms.html]http://realworldstyle.com/forms.html[/URL]

In their sample, a div is being used for each row. In your guys' examples, a paragraph is being used. Would a paragraph work better than a div? Or the other way around?

I'm thinking this would just be someone's preference...
Copy linkTweet thisAlerts:
@ray326Dec 17.2004 — No, my pattern uses divs for the rows. Ps don't really make sense because the contained information is NOT a paragraph.
Copy linkTweet thisAlerts:
@ajimenezauthorDec 17.2004 — So semantically speaking, it's better to use divs.

Makes sense ?
Copy linkTweet thisAlerts:
@David_HarrisonDec 17.2004 — Someone else had this idea and wrote a blog about it. Personally I wouldn't use tables, but Jona put forward quite a convincing [url=http://www.cmmwebdesign.com/blog/chronicles/2004/12/12/displaying-your-forms]arguement[/url] for tables.
Copy linkTweet thisAlerts:
@porcoDec 18.2004 — Or lists could be just as valid... but there's jags of stuff on a google search on making forms display without tables. I think one of the things that can be a drag though is that form elements are actually tied to the OS re display.... Still I use lists quite happily....

http://blog.lindenlangdon.com/prototype2/contact.php

Norty Pig Web Development?
×

Success!

Help @ajimenez spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...