Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Isn't WPF's grid based layout the same as table based layout that's taboo in html?

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)?

like image 654
Gordon Gustafson Avatar asked Oct 04 '09 15:10

Gordon Gustafson


People also ask

What is table layout in HTML?

The table-layout property defines the algorithm used to lay out table cells, rows, and columns. Tip: The main benefit of table-layout: fixed; is that the table renders much faster. On large tables, users will not see any part of the table until the browser has rendered the whole table.

Should I use table or grid?

If your intention is to display a table, an HTML table is your way to go. If your goal is to lay out content on a webpage, CSS grid is one way of doing that. It doesn't have perfect browser support yet so you might want to consider another option for layout, but it is an option. Tables were never meant for layout.

Which is better div or table in HTML?

TABLEs are the correct technology for tabular data. DIVs are the correct technology for page layout and defining objects on the page (along with other block-level objects, i.e. heading, paragraphs, ul tags etc.). Use them both and use them well.

What can I use instead of a table in HTML?

Replace HTML tables with <div>s. In the era of responsive web design the old trend of building websites using HTML tables can't be used anymore. You have to use div tags and style them as required.


1 Answers

The 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.

like image 181
Joey Avatar answered Sep 21 '22 00:09

Joey