0

Possible Duplicate:
Why not use tables for layout in HTML?

When should I use <table>, <div> or <ul>?

What are the main advantages and disadvantages of each one?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Diogo Cardoso
  • 21,637
  • 26
  • 100
  • 138

3 Answers3

5

always try to use each tag according to its semantic character

  • <table> tables are for tabular data, not for layout alignment
  • <ul>is unordered list, it is nice to use <ul> tag for <a> links, because of no CSS fallback
  • <div> div has no semantic meaning, mostly used for alignment, however HTML5 comes with a lot of new tags as <header>, <footer>, <article>, <section>, <aside> which should be used insted of div tag
Matej Janovčík
  • 1,242
  • 12
  • 13
1

Semantically, you should use tables for tabular data, unordered lists for unordered lists, and divisions where there is no semantically-defined element available. However, there is room for interpretation. For example, some developers think of navigation menus as unordered lists, and thus use unordered list tags (probably heavily styled).

Up to and including HTML4, there was a general lack of semantic elements, so developers felt the need to fall back to using divisions very often. However, HTML5 introduces a range of block-level, semantic elements that define document structure and have more meaning than divisions, though they should behave the same. These new tags include article, section, footer, nav, aside and header.

Delan Azabani
  • 79,602
  • 28
  • 170
  • 210
  • The Html5 nav element may also be used when styling nav menus as ULs (http://html5doctor.com/nav-element/). Additionally usage of divs is lessened by the addition of new semantic 'dividers' such as section, article etc – Cargowire May 21 '11 at 13:34
  • This is true; thanks. I'll add some information about what you said to my answer. – Delan Azabani May 21 '11 at 13:37
0

this is a matter of some debate, and I present only my personal view here:
I think you should use tables only when you have to display tabular data.
do NOT use tables for positioning / layout purposes; use divs and css for that.
see this question for more details.

Community
  • 1
  • 1
J. Ed
  • 6,692
  • 4
  • 39
  • 55