# \[OT\] Tables VS divs for form layout

**URL:** <https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438>\
**Category:** Rails\
**Created:** [June 15, 2006, 7:03am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438 "2006-06-15T07:03:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 15, 2006, 7:03am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/1 "2006-06-15T07:03:57Z")

</div>

I’ve been using tables to get my forms to line up. ( I have usually one  
column for labels, and a column for values ). Should I be using divs  
instead? I’ve been reading some CSS design books lately. They tend to  
recommend divs over tables for general page layout stuff. But, what  
about  
the forms elements? What’s the ‘best practice’ in this regard?

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 15, 2006, 7:32am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/2 "2006-06-15T07:32:40Z")

</div>

On 6/15/06, Larry K. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’ve been using tables to get my forms to line up. ( I have usually one  
> column for labels, and a column for values ). Should I be using divs  
> instead? I’ve been reading some CSS design books lately. They tend to  
> recommend divs over tables for general page layout stuff. But, what about  
> the forms elements? What’s the ‘best practice’ in this regard?

Depends on who you ask. I think most developers these days will tell  
you to go with CSS instead of tables, but there are a few who think  
the label/field relationship is table-like enough to justify that  
structure.

So, go with whatever makes you happy. Personally, I use CSS for forms  
(usually with the tag). It’s easy, flexible, and doesn’t  
require a bunch of extra markup.

This article at A List Apart is a good starting point for CSS forms:

> **[Practical CSS Layout Tips, Tricks, & Techniques](https://alistapart.com/article/practicalcss/)**
>
> Think you need HTML tables to craft complex liquid layouts? Not so! In this tip-packed tutorial, Mark Newhouse shares advanced yet practical CSS techniques any working web designer can use.

## Good luck,

Billy M.  
Smart Goat Web Design  
[http://www.smartgoat.com](http://www.smartgoat.com)

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 15, 2006, 7:36am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/3 "2006-06-15T07:36:08Z")

</div>

As I understand “best practice”, it’s fine to use tables for data that  
falls into a tabular structure, and your label/value pairs would  
probably fall into that category.

It’s where you’re trying to present non-tabular data (e.g. layout your  
page with multiple columns, put headers/footers on your page, etc.)  
that you should be using CSS and not tables.

On that basis, stick with tables for getting your forms to line up.

Regards

Dave M.

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 16, 2006, 7:03am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/4 "2006-06-16T07:03:22Z")

</div>

Stealing a bit of inspiration from Backpack, I have started using  
definition lists –

 – a tag I didn’t even know existed until  
recently. It’s like an unordered list (
), but allows you to have aterm , and its definition. This makes it very straightforward to do label/field pairs for forms, and you can style away with CSS.

Asa

Larry K. wrote:

> I’ve been using tables to get my forms to line up. ( I have usually one  
> column for labels, and a column for values ). Should I be using divs  
> instead? I’ve been reading some CSS design books lately. They tend to  
> recommend divs over tables for general page layout stuff. But, what  
> about  
> the forms elements? What’s the ‘best practice’ in this regard?

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 16, 2006, 5:17pm UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/5 "2006-06-16T17:17:57Z")

</div>

Larry K. wrote:

> I’ve been using tables to get my forms to line up. ( I have usually one  
> column for labels, and a column for values ). Should I be using divs  
> instead? I’ve been reading some CSS design books lately. They tend to  
> recommend divs over tables for general page layout stuff. But, what  
> about  
> the forms elements? What’s the ‘best practice’ in this regard?

I agree, divs are better. But for listing I often use tabels as well.  
Depends on what I want to achieve. You can still use tables but define  
table-tags in css to display as tables.

[http://www.w3.org/TR/CSS21/tables.html#value-def-table](http://www.w3.org/TR/CSS21/tables.html#value-def-table)

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 16, 2006, 6:29pm UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/6 "2006-06-16T18:29:43Z")

</div>

Thanks for all the comments and suggestions. I’ve been looking at the  
responses, and learning alot.!  
-Larry

---

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [June 16, 2006, 10:20am UTC](https://www.ruby-forum.com/t/ot-tables-vs-divs-for-form-layout/63438/7 "2006-06-16T10:20:13Z")

</div>

Hi,

For forms where you are asking the user to define something (i.e.  
their name, address, etc) I use the

, definition lists. For when I  
use a form to get a user to move forward in the application or to  
enter data that has already been defined (such as a login) i’ll use a  
  
 to seperate the fields or wrap them in a span, although I don’t  
usually use a span unless I need to do a bit of odd styling.

Mark.

On 16/06/06, Asa H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > I’ve been using tables to get my forms to line up. ( I have usually one  
> > Rails mailing list  
> > removed\_email\_address@domain.invalid  
> > [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–  
[www.markpanay.com](http://www.markpanay.com) - Jargon Free Development  
[www.labellife.com](http://www.labellife.com) - Music Industry 2.0  
[www.tunecast.co.uk](http://www.tunecast.co.uk) - Music for your website
