HTML
  Home arrow HTML arrow Page 3 - HTML, CSS and Tables: The Beauty of Data
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

HTML, CSS and Tables: The Beauty of Data
By: Chris Heilmann
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 74
    2004-11-17

    Table of Contents:
  • HTML, CSS and Tables: The Beauty of Data
  • What is a table?
  • W3C to the rescue
  • Summary needed
  • Styling tables: the days of the spacer GIF
  • Embracing CSS and separating "what is what" and "what it looks like"
  • Our CSS

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    HTML, CSS and Tables: The Beauty of Data - W3C to the rescue


    (Page 3 of 7 )

    To allow assistive technology to give users this kind of information, the W3C extended the original HTML table specification by adding some more structural elements and attributes: THEAD, TFOOT, TH, TBODY, CAPTION, summary, axis, headers and scope. Serialization of tables is a vast subject and covered in many extensive tutorials. Here's a quick introduction to how we can make our tables more accessible for users depending on assistive technology.

    You start with table headers. These TH elements define a cell that gives information about the cells connected to it. In our case, these are the ones in the first row and the ones containing the flight number:

    <table>
      <tr>
        <th>Flight Number:</th>
        <th>From:</th>
        <th>To:</th>
        <th>Departure:</th>
        <th>Arrival:</th>
      </tr>

      <tr> 
        <th>BA 3451</th> 
        <td>Heathrow</td> 
        <td>Nuremberg</td> 
        <td>19:20</td> 
        <td>19:50</td>
      </tr>

      <tr> 
        <th>BA 1254</th> 
        <td>Luton</td> 
        <td>Alicante</td> 
        <td>19:40</td> 
        <td>20:50</td>
      </tr>

      <tr> 
        <th>LH 331</th>
        <td>Heathrow</td> 
        <td>Hamburg</td> 
        <td>20:00</td> 
        <td>20:20</td> 
      </tr>
    </table>

    To tell the data cells which header to connect to, we can use either the "scope" attribute on the header or an ID on the header and a "headers" attribute on the cells. The benefit of a scope is that it is a lot easier, the benefit of headers/ID pairs is that you can create more complex data tables. Scope can be either col for the column or row for the row the TH is in. The headers attribute describes the IDs the cell is connected as a space-separated list. An example using scope would be:

    <table>
      <tr>
        <th scope="col">Flight Number:</th> 
        <th scope="col">From:</th> 
        <th scope="col">To:</th> 
        <th scope="col">Departure:</th> 
        <th scope="col">Arrival:</th> 
      </tr>

      <tr>
        <th scope="row">BA 3451</th>
        <td>Heathrow</td>
        <td>Nuremberg</td>

        <td>19:20</td>
        <td>19:50</td>
      </tr>
      <tr>
        <th scope="row">BA 1254</th>

        <td>Luton</td>
        <td>Alicante</td>
        <td>19:40</td>
        <td>20:50</td>

      </tr>
      <tr>
        <th scope="row">LH 331</th>
        <td>Heathrow</td>

        <td>Hamburg</td>
        <td>20:00</td>
        <td>20:20</td>
      </tr>

    </table>

    And the same table using headers/id:

    <table>
      <tr>
         <th id="fn" scope="col">Flight Number:</th> 
        <th id="fr">From:</th> 
        <th id="to">To:</th> 
        <th id="de">Departure:</th> 
        <th id="ar">Arrival:</th> 
      </tr>

      <tr>
        <th id="f1">BA 3451</th>
        <td headers="f1 fr">Heathrow</td>
        <td headers="f1 to">Nuremberg</td>

        <td headers="f1 de">19:20</td>
        <td headers="f1 ar">19:50</td>
      </tr>
      <tr>

        <th id="f2">BA 1254</th>
        <td headers="f2 fr">Luton</td>
        <td headers="f2 to">Alicante</td>

        <td headers="f2 de">19:40</td>
        <td headers="f2 ar">20:50</td>
      </tr>
      <tr>

        <th id="f3">LH 331</th>
        <td headers="f3 fr">Heathrow</td>
        <td headers="f3 to">Hamburg</td>

        <td headers="f3 de">20:00</td>
        <td headers="f3 ar">20:20</td>
      </tr>
    </table>

     

    More HTML Articles
    More By Chris Heilmann


       · The article is only the start. I hope some of you might be tempted to go on...
     

    HTML ARTICLES

    - Comparing Browser Response to Active Client ...
    - Testing Browser Response to Active Client Pa...
    - Active Client Pages: Completing the Code for...
    - ACP and Browsers: Setting up an Example
    - How Browsers Respond to Active Client Pages
    - Completing a Tree with Active Client Pages
    - HTML Form Verification and ACP
    - Building an ACP Tree
    - Completing an ACP 3D HTML Table Image Gallery
    - Building an ACP 3D HTML Table Image Gallery
    - A Multiple Page Image Gallery with Active Cl...
    - Building an Image Gallery with Active Client...
    - Concluding a Menu for All Browsers
    - A Vertical Menu for All Browsers
    - Downloading Long HTML Pages with ACP







    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
    Stay green...Green IT