3

I have a beginner's question for web development. I am going to create a table in which I am having input fields which I will submit to the server.

What is the common practice for doing this? Should I use html-tables or should I build the tables using stylesheets for positioning and sizing cells, columns, etc.? If both are common practice, what are the pros and cons of using eithor of those?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Nicsoft
  • 3,644
  • 9
  • 41
  • 70

5 Answers5

10

If the content is tabular in nature, logically structured in rows and columns, then the appropriate tags - the tags that describe the structure of the content - are table tags.

Arantor
  • 597
  • 4
  • 15
  • 2
    Yes, the "tables are evil" motto is really "tables are evil when used for styling" (e.g., when you use a table for easy vertical centering). Not using tables for tabular data is almost as bad as using tables for other purposes. – Alberto Martinez Nov 24 '10 at 22:08
  • But you can achieve tabular nature for normal input-fields without using table, can't you? Or is it browser(/OS) specific (I made som tests, but for buttons. It differs between OS: http://stackoverflow.com/questions/2334580/submit-button-not-focused-even-though-tabindex-is-properly-set)? – Nicsoft Nov 25 '10 at 14:07
  • Sure, you can achieve tabular *layout* without table tags. But that's not what I'm getting at - the table tags should be used when the content they are describing is naturally tabular. If it is purely for layout, and that there is no logical basis for making them tabular other than layout, use divs. – Arantor Nov 25 '10 at 14:09
1

You will have folks on both side and some will be nicer than others. Essentially, you use tables for tabular data and not to make a layout for your buttons, logos, etc..

On the other hand, I have some old asp Classic code where we used tables everywhere and it still works great.

If I did it today, I'd use "semantically correct" design where I could which means tables for table data (things displayed in row and column) and the css stuff for layouts.

johnny
  • 19,272
  • 52
  • 157
  • 259
0

I usually use divs for this purpose. The strict definition would be to use tables only to display semantic content.

Patrick
  • 7,903
  • 11
  • 52
  • 87
0

You need to plan carefully first what you need in terms of layout, whether sections are going to be similar, whether there is a lot of sharing or not. And the amount of formatted container your foresee.

It naturally occurs to you that if you can centralise the design on some CSS commands, you will benefit from being able to change looks at once as they are all linked to a common source.

If you are going to have several pages, you will be thinking of having the CSS even on a different page and link to it from others.

Also, you need to know that divs and spans work in a different way than other HTML elements. You will not be able to obtain effects that you would have obtained with a table.

In other words, what you need to do is go to the w3 website and read everything about CSS. Expecting to get an answer in 3 lines about such a huge subject will not help you much.

Alvaro

Alvaro
  • 273
  • 2
  • 3
  • 12
0

My motto for html/css is: "Use the right tag for the job". If its a table let it be a table :)

Pete
  • 11
  • 2