Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why _not_ use html tables for layout [duplicate]

I have been pondering on this over the last couple of days. I'm currently writing a web application (actually adding a screen to an existing, extensive application). I know that using "tables" for layout is a big no-no. But in this app, all of the pages use tables for layout. I decided to do my new page using divs instead. But I came across 2 hurdles.

  1. A lot of the layout stuff that I need to do were already done on the other pages and if I use divs instead, I cant reuse any of that (CSS's and JS and that kinda stuff). That leads to more work and pushes out my completion date.

  2. Some of the more complex parts of the layout are really difficult to do using divs and are really easy to do using tables. Maybe its just me being "old-school"y as I am not much of a web/html kinda guy (I get by).

So, why can't I use tables? I'm not trying to be argumentative, just want to see if there are any compelling arguments beyond the "Its the right thing to do" type stuff. I know it is the right thing to do. I'd like to know why?

like image 628
Adnan Avatar asked Feb 13 '09 09:02

Adnan


People also ask

Why is it not recommended for HTML tables to be used for layout purposes?

HTML tables were originally intended to be used for presenting tabular data, not for layout. The World Wide Web Consortium (W3C®) discourages use of tables for layout because they are striving for a web in which content and structure are completely separate from presentation.

Why are tables the preferred option for creating layouts in HTML email?

As different email service providers have different policy to HTML emails and CSS, it is safer to use HTML table as layout in emails, as CSS (even with inline CSS) may be blocked / filtered, or even worse, half-blocked.

What is the importance of creating HTML tables?

A table in HTML makes a lot of sense when you want to organize data that would look best in a spreadsheet. An HTML table is a great way to display things such as financial data, calendars, pricing, feature comparison, the nutrition facts information panel, bowling scores, and many other tabular data.

Should HTML tables be used as a tool for page layout design or to produce columnar layouts?

The HTML5 specification states: "Tables should not be used as layout aids." This is because tables for layout are difficult for screen readers to differentiate, as previously mentioned.


2 Answers

Implementing your layout with divs, spans, etc, offers a ton more flexibility over tables. Consider floating, auto wrapping of block content vs. horizontal scrolling, specifying where an element should exist on a page, etc. Content is just plain easier to manipulate via CSS when not using tables.

When using tables you're pretty locked in to a strict structure.

Now that doesn't mean it's absolutely the wrong thing to do. From your information I'd likely stick with the theme of the application for consistency sake and implement using tables. Make the best choice for the situation vs. following "the rules" on what's popular right now.

Hope that helps! Ian

like image 104
Ian Suttle Avatar answered Oct 21 '22 04:10

Ian Suttle


Doing css layouts make it easier to change the layout of your page later on. Tables also make your html harder to read and edit.

According to this page..

  • make your redesigns more efficient and less expensive
  • help you maintain visual consistency throughout your sites
  • get you better search engine results when you minimize your markup and use header tags properly. This reduces ratio of code to content.
  • make your sites more accessible to all viewers and user agents.
  • your pages load faster, file sizes will be smaller because table information isn't needed in every page.
  • and give you a competitive edge (that is, job security) as more of the world moves to using Web standards.
like image 42
Bolt_Head Avatar answered Oct 21 '22 06:10

Bolt_Head