Is it correct to use a table in the page layout?

18

I made a data table for a colleague of mine here at work and used a table, except that it had no header, it had only 2 columns. And he told me that people hate table, which was for me to read about Tableless, and I did it, but I can not understand why it is "ugly" or not appropriate to use table.

Example of the table I did was something like this:

Nome:                            João
Banco:                      Santander
QualquerCoisa:                   XXXX
Saldo:                         345,00 <-- em negrito

In the case, my idea is that it is a table, but instead of the titles being on top they are on the left side.

-Edit- What I mean is, what would be the most correct to use in this case? Is it wrong to make a table in this case since in the end it does not look like a table (with borders, titles, and so on)?

    
asked by anonymous 15.04.2015 / 15:49

4 answers

22

Anyone who has told you that in this case you should not use a table should read about tableless because you apparently do not notice anything about it.

Tableless

  Tableless web design (or tableless web layout) is a web design philosophy avoiding the use of HTML tables for purposes of checking the page layout.

     

Instead of HTML tables, you use style sheets (CSS) to organize the elements and text in a web page.

tableless applies to layout

Tableless appeared when using CSS it began to be possible to format a page efficiently without having to use tables to create the graphic aspect of it.

A few years ago the layout was done as follows:

<center>
  <table border="0" width="500" cellspacing="0" cellpadding="0">
    <tbody>
      <tr>
        <td align="left" width="500" valign="top">
          <table border="0" width="500" cellspacing="0" cellpadding="0">
            <tbody>
              <tr>
                <td align="left" width="160" valign="top">Coluna esquerda</td>
                <td align="left" width="180" valign="top">Coluna centro</td>
                <td align="left" width="160" valign="top">Coluna direita</td>
              </tr>
            </tbody>
          </table>
        </td>
      </tr>
    </tbody>
  </table>
</center>

Currently, this does not make sense, because with much less markup and little formatting via CSS we do the same thing:

#grid {
  width: 500px;
  margin: 0 auto;
}
#grid:after {
  visibility: hidden;
  display: block;
  content: "";
  clear: both;
  height: 0;
}
#grid > div {
  float: left;
}
#grid > div {
  width: 160px;
}
#grid .main {
  width: 180px;
}
<div id="grid">
  <div>Coluna Esquerda</div>
  <div class="main">Coluna Centro</div>
  <div>Coluna Direita</div>
</div>

And this is just an example, there are hundreds of solutions for organizing a layout today.

Tableless ! = stop using tables

The term is not synonymous with "stop using tables", the HTML tag <table/> is still used and perfectly valid when we are displaying tabular data. Alias, the same was created for this very thing:

W3c - table

  

On the web, tables are a good way to organize your data in a tabular format.

Just think of this and apply the same logic applied to the layout of the page:

  • Reduced to markup by favoring CSS properties to achieve the same layout with reduced, more scalable maintenance and always with the least possible code in>).

Let's now present tabular data by making use of lots of elements, increasing our markup , making future maintenance of the page and its data, probably resorting to CSS to format things in the same way as a table , instead of just using the <table/> tag?

Of course not!

Summary

Yeah, it should have been up there, but being here forced to read:)

If you are displaying tabular data, the HTML tag <table/> was created for this purpose. If you are making a layout for a page, tableless is the way forward for the issues already highlighted.

    
15.04.2015 / 16:46
12

Table vs Tableless

  

To table or not to table? That's the question.

Whether or not to use tables on a web page depends on your purpose in representing certain data.

It was once the tag <table>

As mentioned in other responses, there was a time when most layouts of websites were done using tables.

For example, most commonly used IDE's, such as Dreamweaver, have a wizard to create site layouts. See the example below:

Soitwascommontostartasitethinkingabouthowmanyrowsorcolumnsitwouldbedividedsowewouldfitalltheelementstogether.Thegreatadvantageofdoinglayoutslikethisisthatitislogicalandintuitive.

However,therearemanylimitationsinlayoutswithtables.

  • Headachewhenanelementneedstooverlapthelayout,suchasasubmenuinalist.
  • Tailorthelayouttomobiledevices.
  • Delayedrendering,becausethebrowserneedstoreadthetableallthewaythroughtoshowitcorrectly.
  • Messycode,usuallywithtablesinsidetableswithintableswithintables...

Andsoon...

Thendivsandspans

Toremedytheselimitations,manywebdesignershavebeguntoimplementlayoutswithgenericdivandspanblockstogetherwithCSSstylemanipulationtechniquestogeneratemoreflexibleandresponsivelayouts.

WiththeadventofHTML5,newtagshavebeenaddedtomakecodingeveneasierbyaddingsemanticstocertainpageelements.Someare:header,footer,sectionandaside.Theyareexemplifiedintheexamplebelow.

Unlikeanormaltable,whereeachcellmustobeythetablepositioningpatterns,theblocksaremoreindependent.Eachblockcanbepositionedindependentlybutrelativetotheotherblocks.

Seetheexamplebelow:

This seems the same thing as a table, but it does away with the limitations mentioned above.

In the HTML code, the layout might look something like this:

<body>
  <header>
    Meu cabeçalho
  </header>

  <aside class="esquerda">
    Menu à esquerda
  </aside>

  <aside class="direita">
    Menu à direita
  </aside>

  <section id="content">
    Conteúdo da página.
  </section>

  <footer>
    Meu rodapé
  </footer>
</body>

So the advantages:

  • More freedom when positioning elements, as it is not necessary to follow exactly the grid of a table.
  • In small screens, for example in cell phones, elements can be arranged in a completely different positions from a large screen using CSS medium queries .
  • The browser is able to require each tag as soon as it receives browser content, so if your page is made up of too much data it will be displayed gradually and not all at once after a long initial delay.
  • You can split the code into different sections and not everything is inside a single table. Using dynamic languages like PHP, JSP, ASP, this allows you to split the code into several files more efficiently and avoid breaking the layout if any larger than expected content is written to the page.

Of course, not everything is flowers. In the beginning, creating a 100% tableless layout was a big headache. The most complicated thing was to create code that would work the same in all browsers.

However, with CSS standardization advancing, evolving browsers, and consolidating HTML and CSS encoding standards, today it is much easier to do this if you do not want to reinvent the wheel.

Thousands and thousands of websites provide examples of how to do this, and there are libraries like Foundation and Bootstrap that allow you to reuse ready-made styles to create your site.

Whether or not to use tables

If you have data that is really tabular, as in the case of representing data from a database, where it is important that columns always have to be aligned, then tables are the most ideal solution.

On the other hand, imagine a photo gallery. On a larger monitor you may want to display 4 photos per line, but by decreasing the table size, 3, 2 or even 1 photos can be displayed, for example in smartphones . Tables simply do not work here.

Do not stop here

One tip to better understand how this works is to go to the Bootstrap page and see how the Grid System works. On the same page, there is a table usage example .

Understanding how both systems work will make it easier to decide when to use both.

    
15.04.2015 / 18:04
8

Tableless is a term that arose when CSS and HTML began to evolve and provide a much wider range of control to Frontend staff.

To better understand, imagine that at that time no divs, spans, and so on were used. The entire layout of the site was "trimmed" and mounted inside tables. Many tables, one inside the other, that is, something very laborious and that still did not allow a good quality. Hence the resistance of many to date with the tables.

However, flexibility is most welcome. The tables have their use, as the name says, to tabulate data. It is not recommended for positioning elements and assembling the layout, which is against the concept of tableless, but for something like your example, it can be used perfectly that will not make your HTML amateur or low quality. An example is the jQuery plugins like the datatable that modernize and streamline the use of tables, as it is meant to be, to tabulate data .

    
15.04.2015 / 16:00
6

The Table tag was created to display a table with tabular data.

So using a table to control the layout of the elements on the page is a bad practice. Because of this, the concept of tableless has been created to use the tables correctly only in the tabular data.

  

Tables should not be used as layout aids. Historically, some Web authors have misused tables in HTML as a way to control their page layout. This usage is non-conforming, because tools attempting to extract tabular data from such documents would obtain very confusing results. In particular, users of accessibility tools like screen readers are likely to find it very difficult to navigate pages with tables used for layout.

     

Translation :

     

Tables should not be used for layout purposes. Historically, some Web developers have used the tables to control the layout of their pages. This usage is a non-compliance, since tabular data-gathering tools from HTML would come across very confusing data. In addition, people who use accessibility tools, such as screen readers, tend to have major problems navigating pages where the layout is done by tables.

Source: link

    
15.04.2015 / 16:02