Both employ the same concept: define some rows and columns and add content into specific positions. But the Grid is the most common WPF layout container, while table based layout in html is very controversial. So why is WPF's grid layout praised and html's table based layout considered "bad" (by some)?
views:
415answers:
1The point is that Grid in WPF is defined to be a layout mechanism, while a table in HTML is for marking up tabular data, something where you would usually use a DataGrid or similar in WPF.
The problem with HTML in this respect is not so much that you're using tables for layout. In fact, the CSS3 Template Layout Module isn't so much different. The problem is that content in tables has no semantic structure and thus is inaccessible to screen readers, search engines and the like. They expect a table to hold tabular data since any visual layout mechanism can't make any sense to something which has no eyesight (such as screen readers, web crawlers or blind people).
In WPF there are various ways to address this. First of all, WPF is for graphical user interface design and as such very visually rooted. That automatically implies a certain unsuited-ness for blind people. Furthermore, web crawlers are not really a concern (ignoring XBAP for a while; haven't seen those in the wild so far). Beyond that, WPF works with existing accessibility technologies in Windows to ensure that screen readers can make sense of the UI in the same way as they could with a traditional Windows application. So you got more accessibility meta-information here than inherent in HTML. Also the only thing that's accesible to the outside is a fully-rendered grid. Not the markup beneath it, but rather a series of controls that are somewhere on the screen. And to those the same rules apply as for any other window too.
Another point against tables for layout in HTML is that you mix content and presentation, making it hard to change only one of those and also making it hard to get to the content alone (akin to the above problem for screen readers and web crawlers). In WPF both are already separated (via data binding) and you can separate them even further if you like by building custom controls to encapsulate parts of a layout, pulling strings and images into resources, &c.
To summarize, HTML had no proper mechanism for building complex and appealing layouts and tables were a solution to that problem (with all inherent weaknesses and problems). WPF on the other hand was built from the ground up with techniques and ways of addressing exactly those shortcomings and they are for the most part actually best practices there.