RSS 2.0 Feed
RSS 2.0


Atom 1.0 Feed
Atom 1.0

  Laying it all out on the Table 


Over the last year or so I've been trying to make by web UIs more CSS driven and not use tables as often as I do. But it is an ongoing battle. Who ever said that old-habits die hard wasn't kidding. The use of tables comes out so natually when I write my markup that it is second nature. It is the way I have always done web UI layout. Problem is that tables are inflexible, have a tendency to get messy fast as you get deeper and deeper nested tables, but worst of all they are slow for the browser to render. Milan Negovan made yet another great post today to share a great idea to speed up tables for those of us struggling to drop our excessive table habits.

The idea is to force column width so the browser does not have to calculate it and do all the resizing using the table-layout property. Doing so will drastically speed up table rendering (by a factor of 100 or so according to Milan)

<table style="table-layout:fixed;"... >

Milan explains that with the table-layout fixed that the browser computes the column widths in the following order:

  1. By using information in the width property for the col or colGroup element.
  2. By using information in the width property for the td elements in the first row.
  3. By dividing the table columns equally, regardless of the size of the content.

If the content of a cell exceeds the fixed width of the column, the content is wrapped or, if wrapping is not possible, it is clipped. However, what this will give you is faster rendering since the browser doesn't have to parse the entire table to calculate the column width. While it is still a better idea to use more semantic markup over table layouts, this at least gives a faster alternative for your tables - especially when you start looking at how most tables contain layers and layers of nested tables.

BTW, as long as we're on the subject, if you do any ASP.NET development at all, then you should be subscribing to Milan. It amazes me how much great content he cranks out. Non-stop useful information, he's definitly saved me a headache or two. Check out his site at AspNetResources.com. He's taking his part in making the web beautiful and practical, one post at a time.




                   



Leave a comment below.

Comments

  1. Fareed Khan 4/18/2005 8:01 AM
    Gravatar
  2. Adawi 12/16/2007 4:27 AM
    Gravatar
    I am try the table-layout:fixed in firefox But it not wor well
    ar ther any solution
  3. 9/19/2009 12:50 AM
    Gravatar
    gxkbycyx - Google Search
Comments have been closed on this topic.



 

News


Also see my CRM Developer blog

Connect:              


Sponsor

Sections